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

Commit fc57851

Browse files
azzJamesHenry
authored andcommitted
New: Support TypeScript 2.4 (fixes #321) (#322)
1 parent b255499 commit fc57851

File tree

6 files changed

+360
-2
lines changed

6 files changed

+360
-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.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

+1
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

+6
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,12 @@ module.exports = function convert(config) {
16021602
break;
16031603
}
16041604

1605+
case SyntaxKind.ImportKeyword:
1606+
Object.assign(result, {
1607+
type: AST_NODE_TYPES.Import
1608+
});
1609+
break;
1610+
16051611
case SyntaxKind.EmptyStatement:
16061612
case SyntaxKind.DebuggerStatement:
16071613
simplyCopy();

package.json

+1-1
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",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import('foo').then(main);

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

+350
Original file line numberDiff line numberDiff line change
@@ -56575,6 +56575,356 @@ Object {
5657556575
}
5657656576
`;
5657756577

56578+
exports[`ecmaFeatures fixtures/experimentalDynamicImport/dynamic-import.src 1`] = `
56579+
Object {
56580+
"body": Array [
56581+
Object {
56582+
"expression": Object {
56583+
"arguments": Array [
56584+
Object {
56585+
"loc": Object {
56586+
"end": Object {
56587+
"column": 23,
56588+
"line": 1,
56589+
},
56590+
"start": Object {
56591+
"column": 19,
56592+
"line": 1,
56593+
},
56594+
},
56595+
"name": "main",
56596+
"range": Array [
56597+
19,
56598+
23,
56599+
],
56600+
"type": "Identifier",
56601+
},
56602+
],
56603+
"callee": Object {
56604+
"computed": false,
56605+
"loc": Object {
56606+
"end": Object {
56607+
"column": 18,
56608+
"line": 1,
56609+
},
56610+
"start": Object {
56611+
"column": 0,
56612+
"line": 1,
56613+
},
56614+
},
56615+
"object": Object {
56616+
"arguments": Array [
56617+
Object {
56618+
"loc": Object {
56619+
"end": Object {
56620+
"column": 12,
56621+
"line": 1,
56622+
},
56623+
"start": Object {
56624+
"column": 7,
56625+
"line": 1,
56626+
},
56627+
},
56628+
"range": Array [
56629+
7,
56630+
12,
56631+
],
56632+
"raw": "'foo'",
56633+
"type": "Literal",
56634+
"value": "foo",
56635+
},
56636+
],
56637+
"callee": Object {
56638+
"loc": Object {
56639+
"end": Object {
56640+
"column": 6,
56641+
"line": 1,
56642+
},
56643+
"start": Object {
56644+
"column": 0,
56645+
"line": 1,
56646+
},
56647+
},
56648+
"range": Array [
56649+
0,
56650+
6,
56651+
],
56652+
"type": "Import",
56653+
},
56654+
"loc": Object {
56655+
"end": Object {
56656+
"column": 13,
56657+
"line": 1,
56658+
},
56659+
"start": Object {
56660+
"column": 0,
56661+
"line": 1,
56662+
},
56663+
},
56664+
"range": Array [
56665+
0,
56666+
13,
56667+
],
56668+
"type": "CallExpression",
56669+
},
56670+
"property": Object {
56671+
"loc": Object {
56672+
"end": Object {
56673+
"column": 18,
56674+
"line": 1,
56675+
},
56676+
"start": Object {
56677+
"column": 14,
56678+
"line": 1,
56679+
},
56680+
},
56681+
"name": "then",
56682+
"range": Array [
56683+
14,
56684+
18,
56685+
],
56686+
"type": "Identifier",
56687+
},
56688+
"range": Array [
56689+
0,
56690+
18,
56691+
],
56692+
"type": "MemberExpression",
56693+
},
56694+
"loc": Object {
56695+
"end": Object {
56696+
"column": 24,
56697+
"line": 1,
56698+
},
56699+
"start": Object {
56700+
"column": 0,
56701+
"line": 1,
56702+
},
56703+
},
56704+
"range": Array [
56705+
0,
56706+
24,
56707+
],
56708+
"type": "CallExpression",
56709+
},
56710+
"loc": Object {
56711+
"end": Object {
56712+
"column": 25,
56713+
"line": 1,
56714+
},
56715+
"start": Object {
56716+
"column": 0,
56717+
"line": 1,
56718+
},
56719+
},
56720+
"range": Array [
56721+
0,
56722+
25,
56723+
],
56724+
"type": "ExpressionStatement",
56725+
},
56726+
],
56727+
"loc": Object {
56728+
"end": Object {
56729+
"column": 25,
56730+
"line": 1,
56731+
},
56732+
"start": Object {
56733+
"column": 0,
56734+
"line": 1,
56735+
},
56736+
},
56737+
"range": Array [
56738+
0,
56739+
25,
56740+
],
56741+
"sourceType": "script",
56742+
"tokens": Array [
56743+
Object {
56744+
"loc": Object {
56745+
"end": Object {
56746+
"column": 6,
56747+
"line": 1,
56748+
},
56749+
"start": Object {
56750+
"column": 0,
56751+
"line": 1,
56752+
},
56753+
},
56754+
"range": Array [
56755+
0,
56756+
6,
56757+
],
56758+
"type": "Keyword",
56759+
"value": "import",
56760+
},
56761+
Object {
56762+
"loc": Object {
56763+
"end": Object {
56764+
"column": 7,
56765+
"line": 1,
56766+
},
56767+
"start": Object {
56768+
"column": 6,
56769+
"line": 1,
56770+
},
56771+
},
56772+
"range": Array [
56773+
6,
56774+
7,
56775+
],
56776+
"type": "Punctuator",
56777+
"value": "(",
56778+
},
56779+
Object {
56780+
"loc": Object {
56781+
"end": Object {
56782+
"column": 12,
56783+
"line": 1,
56784+
},
56785+
"start": Object {
56786+
"column": 7,
56787+
"line": 1,
56788+
},
56789+
},
56790+
"range": Array [
56791+
7,
56792+
12,
56793+
],
56794+
"type": "String",
56795+
"value": "'foo'",
56796+
},
56797+
Object {
56798+
"loc": Object {
56799+
"end": Object {
56800+
"column": 13,
56801+
"line": 1,
56802+
},
56803+
"start": Object {
56804+
"column": 12,
56805+
"line": 1,
56806+
},
56807+
},
56808+
"range": Array [
56809+
12,
56810+
13,
56811+
],
56812+
"type": "Punctuator",
56813+
"value": ")",
56814+
},
56815+
Object {
56816+
"loc": Object {
56817+
"end": Object {
56818+
"column": 14,
56819+
"line": 1,
56820+
},
56821+
"start": Object {
56822+
"column": 13,
56823+
"line": 1,
56824+
},
56825+
},
56826+
"range": Array [
56827+
13,
56828+
14,
56829+
],
56830+
"type": "Punctuator",
56831+
"value": ".",
56832+
},
56833+
Object {
56834+
"loc": Object {
56835+
"end": Object {
56836+
"column": 18,
56837+
"line": 1,
56838+
},
56839+
"start": Object {
56840+
"column": 14,
56841+
"line": 1,
56842+
},
56843+
},
56844+
"range": Array [
56845+
14,
56846+
18,
56847+
],
56848+
"type": "Identifier",
56849+
"value": "then",
56850+
},
56851+
Object {
56852+
"loc": Object {
56853+
"end": Object {
56854+
"column": 19,
56855+
"line": 1,
56856+
},
56857+
"start": Object {
56858+
"column": 18,
56859+
"line": 1,
56860+
},
56861+
},
56862+
"range": Array [
56863+
18,
56864+
19,
56865+
],
56866+
"type": "Punctuator",
56867+
"value": "(",
56868+
},
56869+
Object {
56870+
"loc": Object {
56871+
"end": Object {
56872+
"column": 23,
56873+
"line": 1,
56874+
},
56875+
"start": Object {
56876+
"column": 19,
56877+
"line": 1,
56878+
},
56879+
},
56880+
"range": Array [
56881+
19,
56882+
23,
56883+
],
56884+
"type": "Identifier",
56885+
"value": "main",
56886+
},
56887+
Object {
56888+
"loc": Object {
56889+
"end": Object {
56890+
"column": 24,
56891+
"line": 1,
56892+
},
56893+
"start": Object {
56894+
"column": 23,
56895+
"line": 1,
56896+
},
56897+
},
56898+
"range": Array [
56899+
23,
56900+
24,
56901+
],
56902+
"type": "Punctuator",
56903+
"value": ")",
56904+
},
56905+
Object {
56906+
"loc": Object {
56907+
"end": Object {
56908+
"column": 25,
56909+
"line": 1,
56910+
},
56911+
"start": Object {
56912+
"column": 24,
56913+
"line": 1,
56914+
},
56915+
},
56916+
"range": Array [
56917+
24,
56918+
25,
56919+
],
56920+
"type": "Punctuator",
56921+
"value": ";",
56922+
},
56923+
],
56924+
"type": "Program",
56925+
}
56926+
`;
56927+
5657856928
exports[`ecmaFeatures fixtures/experimentalObjectRestSpread/arg-spread.src 1`] = `
5657956929
Object {
5658056930
"body": Array [

0 commit comments

Comments
 (0)