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

Commit 38aef53

Browse files
JamesHenryilyavolodin
authored andcommitted
Breaking: Updated supported TypeScript version to ~2.2.1 (fixes #149) (#169)
1 parent 25207e0 commit 38aef53

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ A parser that converts TypeScript into an [ESTree](https://github.com/estree/est
66

77
## Supported TypeScript Version
88

9-
The version of TypeScript supported by this parser is `2.0.x`. Please ensure that you are using this version before submitting any issues.
9+
The version of TypeScript supported by this parser is `~2.2.1`. This is reflected in the `peerDependency` requirement within the package.json file.
1010

11-
Due to a bug in the TypeScript Compiler it was not possible to officially support TypeScript `2.1.x`, please see this issue for more details on using `2.1.x`: https://github.com/eslint/typescript-eslint-parser/issues/149
11+
**Please ensure that you are using this version before submitting any issues.**
1212

1313
## Usage
1414

lib/ast-converter.js

+6-17
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,6 @@ function fixExports(node, result, ast) {
261261
* @returns {boolean} is a token
262262
*/
263263
function isToken(node) {
264-
/**
265-
* Note: We treat JsxText like a token (TypeScript doesn't classify it as one),
266-
* to prevent traversing into it and creating unintended addiontal tokens from
267-
* its contents.
268-
*
269-
* It looks like this has been addressed in the master branch of TypeScript, so we can
270-
* look to remove this extra check as part of the 2.2.x support
271-
*/
272-
if (node.kind === ts.SyntaxKind.JsxText) {
273-
return true;
274-
}
275264
return node.kind >= ts.SyntaxKind.FirstToken && node.kind <= ts.SyntaxKind.LastToken;
276265
}
277266

@@ -680,7 +669,7 @@ module.exports = function(ast, extra) {
680669
function deeplyCopy() {
681670
result.type = "TS" + SyntaxKind[node.kind];
682671
Object.keys(node).filter(function(key) {
683-
return !(/^(?:kind|parent|pos|end|flags)$/.test(key));
672+
return !(/^(?:kind|parent|pos|end|flags|modifierFlagsCache)$/.test(key));
684673
}).forEach(function(key) {
685674
if (key === "type") {
686675
result.typeAnnotation = (node.type) ? convertTypeAnnotation(node.type) : null;
@@ -1083,7 +1072,7 @@ module.exports = function(ast, extra) {
10831072
key: convertChild(node.name),
10841073
value: convertChild(node.initializer),
10851074
computed: (node.name.kind === SyntaxKind.ComputedPropertyName),
1086-
static: Boolean(node.flags & ts.NodeFlags.Static),
1075+
static: Boolean(ts.getModifierFlags(node) & ts.ModifierFlags.Static),
10871076
accessibility: getTSNodeAccessibility(node),
10881077
decorators: (node.decorators) ? node.decorators.map(function(d) {
10891078
return convertChild(d.expression);
@@ -1166,7 +1155,7 @@ module.exports = function(ast, extra) {
11661155
key: convertChild(node.name),
11671156
value: method,
11681157
computed: isMethodNameComputed,
1169-
static: Boolean(node.flags & ts.NodeFlags.Static),
1158+
static: Boolean(ts.getModifierFlags(node) & ts.ModifierFlags.Static),
11701159
kind: "method",
11711160
accessibility: getTSNodeAccessibility(node),
11721161
decorators: (node.decorators) ? node.decorators.map(function(d) {
@@ -1188,7 +1177,7 @@ module.exports = function(ast, extra) {
11881177
// TypeScript uses this even for static methods named "constructor"
11891178
case SyntaxKind.Constructor:
11901179

1191-
var constructorIsStatic = Boolean(node.flags & ts.NodeFlags.Static),
1180+
var constructorIsStatic = Boolean(ts.getModifierFlags(node) & ts.ModifierFlags.Static),
11921181
firstConstructorToken = constructorIsStatic ? ts.findNextToken(node.getFirstToken(), ast) : node.getFirstToken(),
11931182
constructorLoc = ast.getLineAndCharacterOfPosition(node.parameters.pos - 1),
11941183
constructor = {
@@ -1441,8 +1430,8 @@ module.exports = function(ast, extra) {
14411430

14421431
// Patterns
14431432

1444-
// Note: TypeScript uses this for both spread and rest expressions
1445-
case SyntaxKind.SpreadElementExpression:
1433+
case SyntaxKind.SpreadElement:
1434+
case SyntaxKind.SpreadAssignment:
14461435
assign(result, {
14471436
type: "SpreadElement",
14481437
argument: convertChild(node.expression)

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"semver": "^4.1.1",
3131
"shelljs": "^0.3.0",
3232
"shelljs-nodecli": "^0.1.1",
33-
"typescript": "~2.0.3"
33+
"typescript": "~2.2.1"
3434
},
3535
"keywords": [
3636
"ast",
@@ -55,6 +55,6 @@
5555
"object-assign": "^4.0.1"
5656
},
5757
"peerDependencies": {
58-
"typescript": "~2.0.3"
58+
"typescript": "~2.2.1"
5959
}
6060
}

0 commit comments

Comments
 (0)