Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 64266bc

Browse files
committed
New: Support TypeScript 2.4 (fixes #321)
1 parent 31ad3c4 commit 64266bc

File tree

6 files changed

+357
-2
lines changed

6 files changed

+357
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A parser that converts TypeScript into an [ESTree](https://github.com/estree/est
88

99
We will always endeavor to support the latest stable version of TypeScript.
1010

11-
The version of TypeScript currently supported by this parser is `~2.3.2`. This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript.
11+
The version of TypeScript currently supported by this parser is `~2.3.2 || ~2.4`. This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript.
1212

1313
If you use a non-supported version of TypeScript, the parser will log a warning to the console.
1414

lib/ast-node-types.js

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module.exports = {
5555
GenericTypeAnnotation: "GenericTypeAnnotation",
5656
Identifier: "Identifier",
5757
IfStatement: "IfStatement",
58+
Import: "Import",
5859
ImportDeclaration: "ImportDeclaration",
5960
ImportDefaultSpecifier: "ImportDefaultSpecifier",
6061
ImportNamespaceSpecifier: "ImportNamespaceSpecifier",

lib/convert.js

+6
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,12 @@ module.exports = function convert(config) {
15541554
});
15551555
break;
15561556

1557+
case SyntaxKind.ImportKeyword:
1558+
Object.assign(result, {
1559+
type: AST_NODE_TYPES.Import
1560+
});
1561+
break;
1562+
15571563
case SyntaxKind.EmptyStatement:
15581564
case SyntaxKind.DebuggerStatement:
15591565
simplyCopy();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"npm-license": "0.3.3",
3131
"shelljs": "0.7.7",
3232
"shelljs-nodecli": "0.1.1",
33-
"typescript": "~2.3.2"
33+
"typescript": "~2.3.2 || ~2.4"
3434
},
3535
"keywords": [
3636
"ast",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
module.exports = {
2+
"type": "Program",
3+
"range": [
4+
0,
5+
25
6+
],
7+
"loc": {
8+
"start": {
9+
"line": 1,
10+
"column": 0
11+
},
12+
"end": {
13+
"line": 1,
14+
"column": 25
15+
}
16+
},
17+
"body": [
18+
{
19+
"type": "ExpressionStatement",
20+
"range": [
21+
0,
22+
25
23+
],
24+
"loc": {
25+
"start": {
26+
"line": 1,
27+
"column": 0
28+
},
29+
"end": {
30+
"line": 1,
31+
"column": 25
32+
}
33+
},
34+
"expression": {
35+
"type": "CallExpression",
36+
"range": [
37+
0,
38+
24
39+
],
40+
"loc": {
41+
"start": {
42+
"line": 1,
43+
"column": 0
44+
},
45+
"end": {
46+
"line": 1,
47+
"column": 24
48+
}
49+
},
50+
"callee": {
51+
"type": "MemberExpression",
52+
"range": [
53+
0,
54+
18
55+
],
56+
"loc": {
57+
"start": {
58+
"line": 1,
59+
"column": 0
60+
},
61+
"end": {
62+
"line": 1,
63+
"column": 18
64+
}
65+
},
66+
"object": {
67+
"type": "CallExpression",
68+
"range": [
69+
0,
70+
13
71+
],
72+
"loc": {
73+
"start": {
74+
"line": 1,
75+
"column": 0
76+
},
77+
"end": {
78+
"line": 1,
79+
"column": 13
80+
}
81+
},
82+
"callee": {
83+
"type": "Import",
84+
"range": [
85+
0,
86+
6
87+
],
88+
"loc": {
89+
"start": {
90+
"line": 1,
91+
"column": 0
92+
},
93+
"end": {
94+
"line": 1,
95+
"column": 6
96+
}
97+
}
98+
},
99+
"arguments": [
100+
{
101+
"type": "Literal",
102+
"range": [
103+
7,
104+
12
105+
],
106+
"loc": {
107+
"start": {
108+
"line": 1,
109+
"column": 7
110+
},
111+
"end": {
112+
"line": 1,
113+
"column": 12
114+
}
115+
},
116+
"value": "foo",
117+
"raw": "'foo'"
118+
}
119+
]
120+
},
121+
"property": {
122+
"type": "Identifier",
123+
"range": [
124+
14,
125+
18
126+
],
127+
"loc": {
128+
"start": {
129+
"line": 1,
130+
"column": 14
131+
},
132+
"end": {
133+
"line": 1,
134+
"column": 18
135+
}
136+
},
137+
"name": "then"
138+
},
139+
"computed": false
140+
},
141+
"arguments": [
142+
{
143+
"type": "Identifier",
144+
"range": [
145+
19,
146+
23
147+
],
148+
"loc": {
149+
"start": {
150+
"line": 1,
151+
"column": 19
152+
},
153+
"end": {
154+
"line": 1,
155+
"column": 23
156+
}
157+
},
158+
"name": "main"
159+
}
160+
]
161+
}
162+
}
163+
],
164+
"sourceType": "script",
165+
"tokens": [
166+
{
167+
"type": "Keyword",
168+
"value": "import",
169+
"range": [
170+
0,
171+
6
172+
],
173+
"loc": {
174+
"start": {
175+
"line": 1,
176+
"column": 0
177+
},
178+
"end": {
179+
"line": 1,
180+
"column": 6
181+
}
182+
}
183+
},
184+
{
185+
"type": "Punctuator",
186+
"value": "(",
187+
"range": [
188+
6,
189+
7
190+
],
191+
"loc": {
192+
"start": {
193+
"line": 1,
194+
"column": 6
195+
},
196+
"end": {
197+
"line": 1,
198+
"column": 7
199+
}
200+
}
201+
},
202+
{
203+
"type": "String",
204+
"value": "'foo'",
205+
"range": [
206+
7,
207+
12
208+
],
209+
"loc": {
210+
"start": {
211+
"line": 1,
212+
"column": 7
213+
},
214+
"end": {
215+
"line": 1,
216+
"column": 12
217+
}
218+
}
219+
},
220+
{
221+
"type": "Punctuator",
222+
"value": ")",
223+
"range": [
224+
12,
225+
13
226+
],
227+
"loc": {
228+
"start": {
229+
"line": 1,
230+
"column": 12
231+
},
232+
"end": {
233+
"line": 1,
234+
"column": 13
235+
}
236+
}
237+
},
238+
{
239+
"type": "Punctuator",
240+
"value": ".",
241+
"range": [
242+
13,
243+
14
244+
],
245+
"loc": {
246+
"start": {
247+
"line": 1,
248+
"column": 13
249+
},
250+
"end": {
251+
"line": 1,
252+
"column": 14
253+
}
254+
}
255+
},
256+
{
257+
"type": "Identifier",
258+
"value": "then",
259+
"range": [
260+
14,
261+
18
262+
],
263+
"loc": {
264+
"start": {
265+
"line": 1,
266+
"column": 14
267+
},
268+
"end": {
269+
"line": 1,
270+
"column": 18
271+
}
272+
}
273+
},
274+
{
275+
"type": "Punctuator",
276+
"value": "(",
277+
"range": [
278+
18,
279+
19
280+
],
281+
"loc": {
282+
"start": {
283+
"line": 1,
284+
"column": 18
285+
},
286+
"end": {
287+
"line": 1,
288+
"column": 19
289+
}
290+
}
291+
},
292+
{
293+
"type": "Identifier",
294+
"value": "main",
295+
"range": [
296+
19,
297+
23
298+
],
299+
"loc": {
300+
"start": {
301+
"line": 1,
302+
"column": 19
303+
},
304+
"end": {
305+
"line": 1,
306+
"column": 23
307+
}
308+
}
309+
},
310+
{
311+
"type": "Punctuator",
312+
"value": ")",
313+
"range": [
314+
23,
315+
24
316+
],
317+
"loc": {
318+
"start": {
319+
"line": 1,
320+
"column": 23
321+
},
322+
"end": {
323+
"line": 1,
324+
"column": 24
325+
}
326+
}
327+
},
328+
{
329+
"type": "Punctuator",
330+
"value": ";",
331+
"range": [
332+
24,
333+
25
334+
],
335+
"loc": {
336+
"start": {
337+
"line": 1,
338+
"column": 24
339+
},
340+
"end": {
341+
"line": 1,
342+
"column": 25
343+
}
344+
}
345+
}
346+
]
347+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import('foo').then(main);

0 commit comments

Comments
 (0)