Skip to content

Commit bf4301d

Browse files
authored
Fix wrong AST (#34)
1 parent ed2b709 commit bf4301d

File tree

3 files changed

+46
-871
lines changed

3 files changed

+46
-871
lines changed

src/context/script-let.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ export class ScriptLetContext {
377377
for (let index = 0; index < fn.params.length; index++) {
378378
const p = fn.params[index]
379379
;(p as any).parent = parents![index]
380+
if (this.ctx.isTypeScript()) {
381+
delete (p as any).typeAnnotation
382+
}
380383
}
381384

382385
// Process for scope

tests/fixtures/parser/ast/ts-promise01-output.json

Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -806,75 +806,6 @@
806806
"error": {
807807
"type": "Identifier",
808808
"name": "error",
809-
"typeAnnotation": {
810-
"type": "TSTypeAnnotation",
811-
"typeAnnotation": {
812-
"type": "TSParenthesizedType",
813-
"typeAnnotation": {
814-
"type": "TSTypeReference",
815-
"typeName": {
816-
"type": "Identifier",
817-
"name": "Error",
818-
"range": [
819-
207,
820-
212
821-
],
822-
"loc": {
823-
"start": {
824-
"line": 10,
825-
"column": 2
826-
},
827-
"end": {
828-
"line": 10,
829-
"column": 7
830-
}
831-
}
832-
},
833-
"range": [
834-
207,
835-
212
836-
],
837-
"loc": {
838-
"start": {
839-
"line": 10,
840-
"column": 2
841-
},
842-
"end": {
843-
"line": 10,
844-
"column": 7
845-
}
846-
}
847-
},
848-
"range": [
849-
206,
850-
213
851-
],
852-
"loc": {
853-
"start": {
854-
"line": 10,
855-
"column": 1
856-
},
857-
"end": {
858-
"line": 10,
859-
"column": 8
860-
}
861-
}
862-
},
863-
"range": [
864-
204,
865-
213
866-
],
867-
"loc": {
868-
"start": {
869-
"line": 9,
870-
"column": 14
871-
},
872-
"end": {
873-
"line": 10,
874-
"column": 8
875-
}
876-
}
877-
},
878809
"range": [
879810
198,
880811
213
@@ -1278,75 +1209,6 @@
12781209
"value": {
12791210
"type": "Identifier",
12801211
"name": "number",
1281-
"typeAnnotation": {
1282-
"type": "TSTypeAnnotation",
1283-
"typeAnnotation": {
1284-
"type": "TSParenthesizedType",
1285-
"typeAnnotation": {
1286-
"type": "TSTypeQuery",
1287-
"exprName": {
1288-
"type": "Identifier",
1289-
"name": "promise",
1290-
"range": [
1291-
166,
1292-
173
1293-
],
1294-
"loc": {
1295-
"start": {
1296-
"line": 8,
1297-
"column": 9
1298-
},
1299-
"end": {
1300-
"line": 8,
1301-
"column": 16
1302-
}
1303-
}
1304-
},
1305-
"range": [
1306-
159,
1307-
173
1308-
],
1309-
"loc": {
1310-
"start": {
1311-
"line": 8,
1312-
"column": 2
1313-
},
1314-
"end": {
1315-
"line": 8,
1316-
"column": 16
1317-
}
1318-
}
1319-
},
1320-
"range": [
1321-
158,
1322-
174
1323-
],
1324-
"loc": {
1325-
"start": {
1326-
"line": 8,
1327-
"column": 1
1328-
},
1329-
"end": {
1330-
"line": 8,
1331-
"column": 17
1332-
}
1333-
}
1334-
},
1335-
"range": [
1336-
156,
1337-
174
1338-
],
1339-
"loc": {
1340-
"start": {
1341-
"line": 7,
1342-
"column": 14
1343-
},
1344-
"end": {
1345-
"line": 8,
1346-
"column": 17
1347-
}
1348-
}
1349-
},
13501212
"range": [
13511213
149,
13521214
174

0 commit comments

Comments
 (0)