Skip to content

Commit

Permalink
fix: wrong token when using lang=ts (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Apr 9, 2024
1 parent b9f00bc commit 44c1704
Show file tree
Hide file tree
Showing 14 changed files with 1,984 additions and 570 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-rockets-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser": patch
---

fix: wrong token when using `lang=ts`
8 changes: 4 additions & 4 deletions src/context/script-let.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ export class ScriptLetContext {
callback(node as E, result);
}

tokens.shift(); // (
tokens.pop(); // )
tokens.pop(); // ;

if (isTS) {
for (const scope of extractTypeNodeScopes(
tsAs!.typeAnnotation,
Expand All @@ -201,10 +205,6 @@ export class ScriptLetContext {

(node as any).parent = parent;

tokens.shift(); // (
tokens.pop(); // )
tokens.pop(); // ;

// Disconnect the tree structure.
exprSt.expression = null as never;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1656,87 +1656,15 @@
},
{
"type": "Identifier",
"value": "c",
"value": "count",
"range": [
194,
195
],
"loc": {
"start": {
"line": 8,
"column": 24
},
"end": {
"line": 8,
"column": 25
}
}
},
{
"type": "Identifier",
"value": "o",
"range": [
195,
196
],
"loc": {
"start": {
"line": 8,
"column": 25
},
"end": {
"line": 8,
"column": 26
}
}
},
{
"type": "Identifier",
"value": "u",
"range": [
196,
197
],
"loc": {
"start": {
"line": 8,
"column": 26
},
"end": {
"line": 8,
"column": 27
}
}
},
{
"type": "Identifier",
"value": "n",
"range": [
197,
198
],
"loc": {
"start": {
"line": 8,
"column": 27
},
"end": {
"line": 8,
"column": 28
}
}
},
{
"type": "Identifier",
"value": "t",
"range": [
198,
199
],
"loc": {
"start": {
"line": 8,
"column": 28
"column": 24
},
"end": {
"line": 8,
Expand All @@ -1746,33 +1674,15 @@
},
{
"type": "Punctuator",
"value": "+",
"value": "++",
"range": [
199,
200
],
"loc": {
"start": {
"line": 8,
"column": 29
},
"end": {
"line": 8,
"column": 30
}
}
},
{
"type": "Punctuator",
"value": "+",
"range": [
200,
201
],
"loc": {
"start": {
"line": 8,
"column": 30
"column": 29
},
"end": {
"line": 8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1837,87 +1837,15 @@
},
{
"type": "Identifier",
"value": "c",
"value": "count",
"range": [
223,
224
],
"loc": {
"start": {
"line": 11,
"column": 24
},
"end": {
"line": 11,
"column": 25
}
}
},
{
"type": "Identifier",
"value": "o",
"range": [
224,
225
],
"loc": {
"start": {
"line": 11,
"column": 25
},
"end": {
"line": 11,
"column": 26
}
}
},
{
"type": "Identifier",
"value": "u",
"range": [
225,
226
],
"loc": {
"start": {
"line": 11,
"column": 26
},
"end": {
"line": 11,
"column": 27
}
}
},
{
"type": "Identifier",
"value": "n",
"range": [
226,
227
],
"loc": {
"start": {
"line": 11,
"column": 27
},
"end": {
"line": 11,
"column": 28
}
}
},
{
"type": "Identifier",
"value": "t",
"range": [
227,
228
],
"loc": {
"start": {
"line": 11,
"column": 28
"column": 24
},
"end": {
"line": 11,
Expand All @@ -1927,33 +1855,15 @@
},
{
"type": "Punctuator",
"value": "+",
"value": "++",
"range": [
228,
229
],
"loc": {
"start": {
"line": 11,
"column": 29
},
"end": {
"line": 11,
"column": 30
}
}
},
{
"type": "Punctuator",
"value": "+",
"range": [
229,
230
],
"loc": {
"start": {
"line": 11,
"column": 30
"column": 29
},
"end": {
"line": 11,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2745,7 +2745,7 @@
}
},
{
"type": "Identifier",
"type": "Numeric",
"value": "1",
"range": [
241,
Expand Down
Loading

0 comments on commit 44c1704

Please sign in to comment.