Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typescript-estree): handle TS4.0 breaking change in TupleType #2197

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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