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

Commit 271b4f1

Browse files
authored
New: Support TypeScript 2.4 (fixes #321) (#322) (#326)
1 parent ea6c3bb commit 271b4f1

File tree

7 files changed

+360
-380
lines changed

7 files changed

+360
-380
lines changed

README.md

Lines changed: 1 addition & 1 deletion
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.4.0`. 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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = {
5656
GenericTypeAnnotation: "GenericTypeAnnotation",
5757
Identifier: "Identifier",
5858
IfStatement: "IfStatement",
59+
Import: "Import",
5960
ImportDeclaration: "ImportDeclaration",
6061
ImportDefaultSpecifier: "ImportDefaultSpecifier",
6162
ImportNamespaceSpecifier: "ImportNamespaceSpecifier",

lib/convert.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,12 @@ module.exports = function convert(config) {
16491649
break;
16501650
}
16511651

1652+
case SyntaxKind.ImportKeyword:
1653+
Object.assign(result, {
1654+
type: AST_NODE_TYPES.Import
1655+
});
1656+
break;
1657+
16521658
case SyntaxKind.EmptyStatement:
16531659
case SyntaxKind.DebuggerStatement:
16541660
simplyCopy();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"npm-license": "0.3.3",
2727
"shelljs": "0.7.7",
2828
"shelljs-nodecli": "0.1.1",
29-
"typescript": "~2.3.2"
29+
"typescript": "~2.4.0"
3030
},
3131
"keywords": [
3232
"ast",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import('foo').then(main);

tests/lib/__snapshots__/ecma-features.js.snap

Lines changed: 350 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57916,6 +57916,356 @@ Object {
5791657916
}
5791757917
`;
5791857918

57919+
exports[`ecmaFeatures fixtures/experimentalDynamicImport/dynamic-import.src 1`] = `
57920+
Object {
57921+
"body": Array [
57922+
Object {
57923+
"expression": Object {
57924+
"arguments": Array [
57925+
Object {
57926+
"loc": Object {
57927+
"end": Object {
57928+
"column": 23,
57929+
"line": 1,
57930+
},
57931+
"start": Object {
57932+
"column": 19,
57933+
"line": 1,
57934+
},
57935+
},
57936+
"name": "main",
57937+
"range": Array [
57938+
19,
57939+
23,
57940+
],
57941+
"type": "Identifier",
57942+
},
57943+
],
57944+
"callee": Object {
57945+
"computed": false,
57946+
"loc": Object {
57947+
"end": Object {
57948+
"column": 18,
57949+
"line": 1,
57950+
},
57951+
"start": Object {
57952+
"column": 0,
57953+
"line": 1,
57954+
},
57955+
},
57956+
"object": Object {
57957+
"arguments": Array [
57958+
Object {
57959+
"loc": Object {
57960+
"end": Object {
57961+
"column": 12,
57962+
"line": 1,
57963+
},
57964+
"start": Object {
57965+
"column": 7,
57966+
"line": 1,
57967+
},
57968+
},
57969+
"range": Array [
57970+
7,
57971+
12,
57972+
],
57973+
"raw": "'foo'",
57974+
"type": "Literal",
57975+
"value": "foo",
57976+
},
57977+
],
57978+
"callee": Object {
57979+
"loc": Object {
57980+
"end": Object {
57981+
"column": 6,
57982+
"line": 1,
57983+
},
57984+
"start": Object {
57985+
"column": 0,
57986+
"line": 1,
57987+
},
57988+
},
57989+
"range": Array [
57990+
0,
57991+
6,
57992+
],
57993+
"type": "Import",
57994+
},
57995+
"loc": Object {
57996+
"end": Object {
57997+
"column": 13,
57998+
"line": 1,
57999+
},
58000+
"start": Object {
58001+
"column": 0,
58002+
"line": 1,
58003+
},
58004+
},
58005+
"range": Array [
58006+
0,
58007+
13,
58008+
],
58009+
"type": "CallExpression",
58010+
},
58011+
"property": Object {
58012+
"loc": Object {
58013+
"end": Object {
58014+
"column": 18,
58015+
"line": 1,
58016+
},
58017+
"start": Object {
58018+
"column": 14,
58019+
"line": 1,
58020+
},
58021+
},
58022+
"name": "then",
58023+
"range": Array [
58024+
14,
58025+
18,
58026+
],
58027+
"type": "Identifier",
58028+
},
58029+
"range": Array [
58030+
0,
58031+
18,
58032+
],
58033+
"type": "MemberExpression",
58034+
},
58035+
"loc": Object {
58036+
"end": Object {
58037+
"column": 24,
58038+
"line": 1,
58039+
},
58040+
"start": Object {
58041+
"column": 0,
58042+
"line": 1,
58043+
},
58044+
},
58045+
"range": Array [
58046+
0,
58047+
24,
58048+
],
58049+
"type": "CallExpression",
58050+
},
58051+
"loc": Object {
58052+
"end": Object {
58053+
"column": 25,
58054+
"line": 1,
58055+
},
58056+
"start": Object {
58057+
"column": 0,
58058+
"line": 1,
58059+
},
58060+
},
58061+
"range": Array [
58062+
0,
58063+
25,
58064+
],
58065+
"type": "ExpressionStatement",
58066+
},
58067+
],
58068+
"loc": Object {
58069+
"end": Object {
58070+
"column": 25,
58071+
"line": 1,
58072+
},
58073+
"start": Object {
58074+
"column": 0,
58075+
"line": 1,
58076+
},
58077+
},
58078+
"range": Array [
58079+
0,
58080+
25,
58081+
],
58082+
"sourceType": "script",
58083+
"tokens": Array [
58084+
Object {
58085+
"loc": Object {
58086+
"end": Object {
58087+
"column": 6,
58088+
"line": 1,
58089+
},
58090+
"start": Object {
58091+
"column": 0,
58092+
"line": 1,
58093+
},
58094+
},
58095+
"range": Array [
58096+
0,
58097+
6,
58098+
],
58099+
"type": "Keyword",
58100+
"value": "import",
58101+
},
58102+
Object {
58103+
"loc": Object {
58104+
"end": Object {
58105+
"column": 7,
58106+
"line": 1,
58107+
},
58108+
"start": Object {
58109+
"column": 6,
58110+
"line": 1,
58111+
},
58112+
},
58113+
"range": Array [
58114+
6,
58115+
7,
58116+
],
58117+
"type": "Punctuator",
58118+
"value": "(",
58119+
},
58120+
Object {
58121+
"loc": Object {
58122+
"end": Object {
58123+
"column": 12,
58124+
"line": 1,
58125+
},
58126+
"start": Object {
58127+
"column": 7,
58128+
"line": 1,
58129+
},
58130+
},
58131+
"range": Array [
58132+
7,
58133+
12,
58134+
],
58135+
"type": "String",
58136+
"value": "'foo'",
58137+
},
58138+
Object {
58139+
"loc": Object {
58140+
"end": Object {
58141+
"column": 13,
58142+
"line": 1,
58143+
},
58144+
"start": Object {
58145+
"column": 12,
58146+
"line": 1,
58147+
},
58148+
},
58149+
"range": Array [
58150+
12,
58151+
13,
58152+
],
58153+
"type": "Punctuator",
58154+
"value": ")",
58155+
},
58156+
Object {
58157+
"loc": Object {
58158+
"end": Object {
58159+
"column": 14,
58160+
"line": 1,
58161+
},
58162+
"start": Object {
58163+
"column": 13,
58164+
"line": 1,
58165+
},
58166+
},
58167+
"range": Array [
58168+
13,
58169+
14,
58170+
],
58171+
"type": "Punctuator",
58172+
"value": ".",
58173+
},
58174+
Object {
58175+
"loc": Object {
58176+
"end": Object {
58177+
"column": 18,
58178+
"line": 1,
58179+
},
58180+
"start": Object {
58181+
"column": 14,
58182+
"line": 1,
58183+
},
58184+
},
58185+
"range": Array [
58186+
14,
58187+
18,
58188+
],
58189+
"type": "Identifier",
58190+
"value": "then",
58191+
},
58192+
Object {
58193+
"loc": Object {
58194+
"end": Object {
58195+
"column": 19,
58196+
"line": 1,
58197+
},
58198+
"start": Object {
58199+
"column": 18,
58200+
"line": 1,
58201+
},
58202+
},
58203+
"range": Array [
58204+
18,
58205+
19,
58206+
],
58207+
"type": "Punctuator",
58208+
"value": "(",
58209+
},
58210+
Object {
58211+
"loc": Object {
58212+
"end": Object {
58213+
"column": 23,
58214+
"line": 1,
58215+
},
58216+
"start": Object {
58217+
"column": 19,
58218+
"line": 1,
58219+
},
58220+
},
58221+
"range": Array [
58222+
19,
58223+
23,
58224+
],
58225+
"type": "Identifier",
58226+
"value": "main",
58227+
},
58228+
Object {
58229+
"loc": Object {
58230+
"end": Object {
58231+
"column": 24,
58232+
"line": 1,
58233+
},
58234+
"start": Object {
58235+
"column": 23,
58236+
"line": 1,
58237+
},
58238+
},
58239+
"range": Array [
58240+
23,
58241+
24,
58242+
],
58243+
"type": "Punctuator",
58244+
"value": ")",
58245+
},
58246+
Object {
58247+
"loc": Object {
58248+
"end": Object {
58249+
"column": 25,
58250+
"line": 1,
58251+
},
58252+
"start": Object {
58253+
"column": 24,
58254+
"line": 1,
58255+
},
58256+
},
58257+
"range": Array [
58258+
24,
58259+
25,
58260+
],
58261+
"type": "Punctuator",
58262+
"value": ";",
58263+
},
58264+
],
58265+
"type": "Program",
58266+
}
58267+
`;
58268+
5791958269
exports[`ecmaFeatures fixtures/experimentalObjectRestSpread/arg-spread.src 1`] = `
5792058270
Object {
5792158271
"body": Array [

0 commit comments

Comments
 (0)