Skip to content

Commit

Permalink
fix(typescript-estree): handle TS4.0 breaking change in TupleType (#2197
Browse files Browse the repository at this point in the history
)
  • Loading branch information
uniqueiniquity committed Jun 9, 2020
1 parent a2ffe55 commit 5d68129
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions .prettierignore
Expand Up @@ -5,6 +5,7 @@
**/shared-fixtures
**/.vscode
**/.nyc_output
**/.vs
packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js
.github
packages/eslint-plugin/src/configs/*.json
Expand Down
9 changes: 8 additions & 1 deletion packages/typescript-estree/src/convert.ts
Expand Up @@ -2617,9 +2617,16 @@ export class Converter {
});
}
case SyntaxKind.TupleType: {
// In TS 4.0, the `elementTypes` property was changed to `elements`.
// To support both at compile time, we cast to access the newer version
// if the former does not exist.
const elementTypes = node.elementTypes
? node.elementTypes.map(el => this.convertType(el))
: (node as any).elements.map((el: ts.Node) => this.convertType(el));

return this.createNode<TSESTree.TSTupleType>(node, {
type: AST_NODE_TYPES.TSTupleType,
elementTypes: node.elementTypes.map(el => this.convertType(el)),
elementTypes,
});
}
case SyntaxKind.UnionType: {
Expand Down

0 comments on commit 5d68129

Please sign in to comment.