Skip to content
Permalink
Browse files

feat(typescript-estree): support for parsing 3.7 features (#1045)

  • Loading branch information...
bradzacher committed Oct 14, 2019
1 parent 854620e commit 623febfca0b5afbbdc7297d65617d80ac4872513
Showing with 20,524 additions and 6,839 deletions.
  1. +3 −0 .vscode/launch.json
  2. +2 −2 .vscode/settings.json
  3. +2 −2 README.md
  4. +4 −1 package.json
  5. +2 −2 packages/eslint-plugin-tslint/tsconfig.json
  6. +0 −2 packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts
  7. +5 −1 packages/eslint-plugin/src/rules/indent.ts
  8. +3 −1 packages/eslint-plugin/src/rules/prefer-readonly.ts
  9. +2 −2 packages/eslint-plugin/tsconfig.json
  10. +2 −2 packages/experimental-utils/tsconfig.json
  11. +2 −0 packages/parser/src/visitor-keys.ts
  12. +13 −0 packages/parser/tests/lib/__snapshots__/comments.ts.snap
  13. +5,163 −2,153 packages/parser/tests/lib/__snapshots__/typescript.ts.snap
  14. +1 −1 packages/parser/tests/lib/jsx.ts
  15. +2 −1 packages/parser/tsconfig.build.json
  16. +2 −2 packages/parser/tsconfig.json
  17. 0 ...asics/{type-assertion-arrow-function.src.ts → angle-bracket-type-assertion-arrow-function.src.ts}
  18. 0 ...fixtures/fixtures/typescript/basics/{type-assertion.src.ts → angle-bracket-type-assertion.src.ts}
  19. +3 −0 packages/shared-fixtures/fixtures/typescript/basics/nullish-coalescing.src.ts
  20. +12 −0 packages/shared-fixtures/fixtures/typescript/basics/optional-chain-call.src.ts
  21. +8 −0 packages/shared-fixtures/fixtures/typescript/basics/optional-chain-element-access.src.ts
  22. +7 −0 packages/shared-fixtures/fixtures/typescript/basics/optional-chain.src.ts
  23. +3 −0 packages/shared-fixtures/fixtures/typescript/basics/type-assertion-in-arrow-function.src.ts
  24. +3 −0 packages/shared-fixtures/fixtures/typescript/basics/type-assertion-in-function.src.ts
  25. +3 −0 packages/shared-fixtures/fixtures/typescript/basics/type-assertion-in-interface.src.ts
  26. +8 −0 packages/shared-fixtures/fixtures/typescript/basics/type-assertion-in-method.src.ts
  27. +3 −0 ...ges/shared-fixtures/fixtures/typescript/basics/type-assertion-with-guard-in-arrow-function.src.ts
  28. +3 −0 packages/shared-fixtures/fixtures/typescript/basics/type-assertion-with-guard-in-function.src.ts
  29. +3 −0 packages/shared-fixtures/fixtures/typescript/basics/type-assertion-with-guard-in-interface.src.ts
  30. +8 −0 packages/shared-fixtures/fixtures/typescript/basics/type-assertion-with-guard-in-method.src.ts
  31. +6 −1 packages/shared-fixtures/package.json
  32. +12 −0 packages/shared-fixtures/tsconfig.build.json
  33. +10 −0 packages/shared-fixtures/tsconfig.json
  34. +99 −32 packages/typescript-estree/src/convert.ts
  35. +14 −11 packages/typescript-estree/src/node-utils.ts
  36. +1 −1 packages/typescript-estree/src/parser.ts
  37. +2 −0 packages/typescript-estree/src/ts-estree/ast-node-types.ts
  38. +28 −7 packages/typescript-estree/src/ts-estree/ts-estree.ts
  39. +262 −14 packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
  40. +2 −0 packages/typescript-estree/tests/ast-alignment/parse.ts
  41. +13 −0 packages/typescript-estree/tests/lib/__snapshots__/comments.ts.snap
  42. +45 −0 packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap
  43. +26 −2 packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
  44. +2 −0 packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.ts.snap
  45. +1 −0 packages/typescript-estree/tests/lib/__snapshots__/tsx.ts.snap
  46. +14,199 −2,772 packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap
  47. +1 −1 packages/typescript-estree/tests/lib/jsx.ts
  48. +3 −4 packages/typescript-estree/tests/lib/semanticInfo.ts
  49. +4 −3 packages/typescript-estree/tsconfig.json
  50. +522 −1,819 yarn.lock
@@ -12,6 +12,7 @@
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": [
"--runInBand",
"--no-coverage",
// needs the '' around it so that the () are properly handled
"'tests/(.+/)?${fileBasenameNoExtension}'"
],
@@ -27,6 +28,8 @@
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": [
"--runInBand",
"--no-cache",
"--no-coverage",
"${relativeFile}"
],
"sourceMaps": true,
@@ -22,6 +22,6 @@
"javascript.preferences.importModuleSpecifier": "auto",
"typescript.preferences.importModuleSpecifier": "auto",
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"editor.defaultFormatter": "esbenp.prettier-vscode"
"typescript.preferences.quoteStyle": "single",
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
@@ -235,9 +235,9 @@ The latest version under the `canary` tag **(latest commit to master)** is:

## Supported TypeScript Version

We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript.
We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript. In some cases, we may even be able to support additional pre-releases (i.e. betas and release candidates) of TypeScript, but only if doing so does not require us to compromise on support for the latest stable version.

**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.7.0`.**
**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.8.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.

@@ -73,10 +73,13 @@
"ts-jest": "^24.0.0",
"ts-node": "^8.3.0",
"tslint": "^5.19.0",
"typescript": ">=3.2.1 <3.7.0"
"typescript": ">=3.2.1 <3.8.0 >3.7.0-dev.0"
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"resolutions": {
"typescript": "^3.7.0-beta"
}
}
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"rootDir": ".",
"noEmit": true
"composite": false,
"rootDir": "."
},
"include": ["src", "tests"],
"exclude": ["tests/test-project", "tests/test-tslint-rules-directory"]
@@ -90,8 +90,6 @@ export default util.createRule({
case AST_NODE_TYPES.TSTypeLiteral:
return node.members;
}

return [];
}

/**
@@ -292,7 +292,7 @@ export default util.createRule<Options, MessageIds>({
range: moduleReference.range,
loc: moduleReference.loc,
},
},
} as TSESTree.VariableDeclarator,
],

// location data
@@ -313,6 +313,8 @@ export default util.createRule<Options, MessageIds>({
parent: node.parent,
range: node.range,
loc: node.loc,
optional: false,
computed: true,
});
},

@@ -420,6 +422,8 @@ export default util.createRule<Options, MessageIds>({
parent: node.parent,
range: node.range,
loc: node.loc,
optional: false,
computed: false,
});
},

@@ -162,7 +162,9 @@ export default util.createRule<Options, MessageIds>({
function getEsNodesFromViolatingNode(
violatingNode: ParameterOrPropertyDeclaration,
): { esNode: TSESTree.Node; nameNode: TSESTree.Node } {
if (ts.isParameterPropertyDeclaration(violatingNode)) {
if (
ts.isParameterPropertyDeclaration(violatingNode, violatingNode.parent)
) {
return {
esNode: parserServices.tsNodeToESTreeNodeMap.get(violatingNode.name),
nameNode: parserServices.tsNodeToESTreeNodeMap.get(
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"rootDir": ".",
"noEmit": true
"composite": false,
"rootDir": "."
},
"include": ["src", "typings", "tests", "tools"]
}
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"rootDir": ".",
"noEmit": true
"composite": false,
"rootDir": "."
},
"include": ["src", "typings", "tests", "tools"]
}
@@ -43,6 +43,8 @@ export const visitorKeys = eslintVisitorKeys.unionWith({
BigIntLiteral: [],
ClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
Decorator: ['expression'],
OptionalCallExpression: eslintVisitorKeys.KEYS.CallExpression,
OptionalMemberExpression: eslintVisitorKeys.KEYS.MemberExpression,
TSAbstractClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
TSAbstractKeyword: [],
TSAbstractMethodDefinition: ['key', 'value'],
@@ -36,6 +36,7 @@ Object {
"line": 2,
},
},
"optional": false,
"range": Array [
6,
9,
@@ -11708,6 +11709,7 @@ Object {
"line": 2,
},
},
"optional": false,
"range": Array [
24,
37,
@@ -12589,6 +12591,7 @@ Object {
"line": 2,
},
},
"optional": false,
"range": Array [
24,
37,
@@ -14189,6 +14192,7 @@ Object {
"line": 3,
},
},
"optional": false,
"range": Array [
36,
41,
@@ -15965,6 +15969,7 @@ Object {
"line": 6,
},
},
"optional": false,
"range": Array [
82,
88,
@@ -16485,6 +16490,7 @@ Object {
"line": 7,
},
},
"optional": false,
"range": Array [
126,
132,
@@ -18181,6 +18187,7 @@ Object {
],
"type": "Identifier",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {
@@ -18277,6 +18284,7 @@ Object {
],
"type": "Identifier",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {
@@ -18301,6 +18309,7 @@ Object {
],
"type": "MemberExpression",
},
"optional": false,
"property": Object {
"left": Object {
"computed": false,
@@ -18344,6 +18353,7 @@ Object {
],
"type": "Identifier",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {
@@ -18368,6 +18378,7 @@ Object {
],
"type": "MemberExpression",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {
@@ -18463,6 +18474,7 @@ Object {
"line": 6,
},
},
"optional": false,
"range": Array [
161,
218,
@@ -18552,6 +18564,7 @@ Object {
],
"type": "Identifier",
},
"optional": false,
"property": Object {
"loc": Object {
"end": Object {

0 comments on commit 623febf

Please sign in to comment.
You can’t perform that action at this time.