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

Breaking: Updated supported TypeScript version to ~2.2.1 (fixes #149) #169

Merged
merged 1 commit into from
Feb 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ A parser that converts TypeScript into an [ESTree](https://github.com/estree/est

## Supported TypeScript Version

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

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
**Please ensure that you are using this version before submitting any issues.**

## Usage

Expand Down
23 changes: 6 additions & 17 deletions lib/ast-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,6 @@ function fixExports(node, result, ast) {
* @returns {boolean} is a token
*/
function isToken(node) {
/**
* Note: We treat JsxText like a token (TypeScript doesn't classify it as one),
* to prevent traversing into it and creating unintended addiontal tokens from
* its contents.
*
* It looks like this has been addressed in the master branch of TypeScript, so we can
* look to remove this extra check as part of the 2.2.x support
*/
if (node.kind === ts.SyntaxKind.JsxText) {
return true;
}
return node.kind >= ts.SyntaxKind.FirstToken && node.kind <= ts.SyntaxKind.LastToken;
}

Expand Down Expand Up @@ -680,7 +669,7 @@ module.exports = function(ast, extra) {
function deeplyCopy() {
result.type = "TS" + SyntaxKind[node.kind];
Object.keys(node).filter(function(key) {
return !(/^(?:kind|parent|pos|end|flags)$/.test(key));
return !(/^(?:kind|parent|pos|end|flags|modifierFlagsCache)$/.test(key));
}).forEach(function(key) {
if (key === "type") {
result.typeAnnotation = (node.type) ? convertTypeAnnotation(node.type) : null;
Expand Down Expand Up @@ -1083,7 +1072,7 @@ module.exports = function(ast, extra) {
key: convertChild(node.name),
value: convertChild(node.initializer),
computed: (node.name.kind === SyntaxKind.ComputedPropertyName),
static: Boolean(node.flags & ts.NodeFlags.Static),
static: Boolean(ts.getModifierFlags(node) & ts.ModifierFlags.Static),
accessibility: getTSNodeAccessibility(node),
decorators: (node.decorators) ? node.decorators.map(function(d) {
return convertChild(d.expression);
Expand Down Expand Up @@ -1166,7 +1155,7 @@ module.exports = function(ast, extra) {
key: convertChild(node.name),
value: method,
computed: isMethodNameComputed,
static: Boolean(node.flags & ts.NodeFlags.Static),
static: Boolean(ts.getModifierFlags(node) & ts.ModifierFlags.Static),
kind: "method",
accessibility: getTSNodeAccessibility(node),
decorators: (node.decorators) ? node.decorators.map(function(d) {
Expand All @@ -1188,7 +1177,7 @@ module.exports = function(ast, extra) {
// TypeScript uses this even for static methods named "constructor"
case SyntaxKind.Constructor:

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

// Patterns

// Note: TypeScript uses this for both spread and rest expressions
case SyntaxKind.SpreadElementExpression:
case SyntaxKind.SpreadElement:
case SyntaxKind.SpreadAssignment:
assign(result, {
type: "SpreadElement",
argument: convertChild(node.expression)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"semver": "^4.1.1",
"shelljs": "^0.3.0",
"shelljs-nodecli": "^0.1.1",
"typescript": "~2.0.3"
"typescript": "~2.2.1"
},
"keywords": [
"ast",
Expand All @@ -55,6 +55,6 @@
"object-assign": "^4.0.1"
},
"peerDependencies": {
"typescript": "~2.0.3"
"typescript": "~2.2.1"
}
}