Skip to content

Commit

Permalink
chore: update ast alignment tests and update babel to 7.18.2 (#5074)
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed May 25, 2022
1 parent 5586ec4 commit 73324aa
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 466 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -56,9 +56,9 @@
},
"devDependencies": {
"@babel/code-frame": "^7.16.7",
"@babel/eslint-parser": "^7.17.0",
"@babel/parser": "^7.17.0",
"@babel/types": "^7.17.10",
"@babel/eslint-parser": "^7.18.2",
"@babel/parser": "^7.18.0",
"@babel/types": "^7.18.2",
"@commitlint/cli": "^16.2.4",
"@commitlint/config-conventional": "^16.2.4",
"@nrwl/cli": "14.1.4",
Expand Down
15 changes: 5 additions & 10 deletions packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
Expand Up @@ -365,7 +365,7 @@ tester.addFixturePatternConfig('typescript/basics', {
/**
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
* babel hard fails on computed string enum members, but TS doesn't
* https://github.com/babel/babel/issues/12683
* @see https://github.com/babel/babel/issues/12683
*/
'export-named-enum-computed-string',
/**
Expand Down Expand Up @@ -455,8 +455,8 @@ tester.addFixturePatternConfig('typescript/expressions', {
fileType: 'ts',
ignore: [
/**
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
* Babel doesn't support TS 4.7 new features yet.
* Produced AST is different
* TODO: investigate in more details
*/
'instantiation-expression',
],
Expand Down Expand Up @@ -492,13 +492,8 @@ tester.addFixturePatternConfig('typescript/types', {
'template-literal-type-3',
'template-literal-type-4',
/**
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
* Babel doesn't support TS 4.7 new feature yet.
*/
'conditional-infer-with-constraint',
/**
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
* Babel doesn't support TS 4.7 new features yet.
* Reported range differs between ts-estree and Babel
* @see https://github.com/babel/babel/issues/14589
*/
'optional-variance-in',
'optional-variance-out',
Expand Down
32 changes: 22 additions & 10 deletions packages/typescript-estree/tests/ast-alignment/utils.ts
Expand Up @@ -63,7 +63,8 @@ export function preprocessBabylonAST(ast: File): any {
],
{
/**
* Awaiting feedback on Babel issue https://github.com/babel/babel/issues/9231
* Once we use babel 8, this can be removed.
* @see https://github.com/babel/babel/pull/13709
*/
TSCallSignatureDeclaration(node) {
if (node.typeAnnotation) {
Expand All @@ -76,7 +77,8 @@ export function preprocessBabylonAST(ast: File): any {
}
},
/**
* Awaiting feedback on Babel issue https://github.com/babel/babel/issues/9231
* Once we use babel 8, this can be removed.
* @see https://github.com/babel/babel/pull/13709
*/
TSConstructSignatureDeclaration(node) {
if (node.typeAnnotation) {
Expand All @@ -89,7 +91,8 @@ export function preprocessBabylonAST(ast: File): any {
}
},
/**
* Awaiting feedback on Babel issue https://github.com/babel/babel/issues/9231
* Once we use babel 8, this can be removed.
* @see https://github.com/babel/babel/pull/13709
*/
TSFunctionType(node) {
if (node.typeAnnotation) {
Expand All @@ -102,7 +105,8 @@ export function preprocessBabylonAST(ast: File): any {
}
},
/**
* Awaiting feedback on Babel issue https://github.com/babel/babel/issues/9231
* Once we use babel 8, this can be removed.
* @see https://github.com/babel/babel/pull/13709
*/
TSConstructorType(node) {
if (node.typeAnnotation) {
Expand All @@ -115,7 +119,8 @@ export function preprocessBabylonAST(ast: File): any {
}
},
/**
* Awaiting feedback on Babel issue https://github.com/babel/babel/issues/9231
* Once we use babel 8, this can be removed.
* @see https://github.com/babel/babel/pull/13709
*/
TSMethodSignature(node) {
if (node.typeAnnotation) {
Expand Down Expand Up @@ -150,7 +155,11 @@ export function preprocessBabylonAST(ast: File): any {
type: AST_NODE_TYPES.Identifier,
};
}
// Babel does not support TS 4.7 optional variance yet.
/**
* TS 4.7: optional variance
* babel: sets in/out property as true/undefined
* ts-estree: sets in/out property as true/false
*/
if (!node.in) {
node.in = false;
}
Expand All @@ -169,15 +178,14 @@ export function preprocessBabylonAST(ast: File): any {
}
/**
* TS 4.3: overrides on class members
* Babel doesn't ever emit a false override flag
* babel: sets override property as true/undefined
* ts-estree: sets override property as true/false
*/
if (node.override == null) {
node.override = false;
}
},
PropertyDefinition(node) {
// babel does not
// node.type = AST_NODE_TYPES.PropertyDefinition;
/**
* Babel: ClassProperty + abstract: true
* ts-estree: TSAbstractClassProperty
Expand All @@ -204,6 +212,10 @@ export function preprocessBabylonAST(ast: File): any {
}
},
TSExpressionWithTypeArguments(node, parent: any) {
/**
* Babel: TSExpressionWithTypeArguments
* ts-estree: TSClassImplements or TSInterfaceHeritage
*/
if (parent.type === AST_NODE_TYPES.TSInterfaceDeclaration) {
node.type = AST_NODE_TYPES.TSInterfaceHeritage;
} else if (
Expand Down Expand Up @@ -271,7 +283,7 @@ export function preprocessBabylonAST(ast: File): any {
},
/**
* babel 7.17.x introduced index property to location data to 2 node types
* TODO: report this to babel
* @see https://github.com/babel/babel/issues/14590
*/
TSEnumDeclaration(node: any) {
if (node.loc?.start?.index) {
Expand Down
2 changes: 1 addition & 1 deletion packages/website/package.json
Expand Up @@ -14,7 +14,7 @@
"test:open": "cypress open"
},
"dependencies": {
"@babel/runtime": "7.18.0",
"@babel/runtime": "^7.18.2",
"@docusaurus/core": "2.0.0-beta.20",
"@docusaurus/preset-classic": "2.0.0-beta.20",
"@docusaurus/remark-plugin-npm2yarn": "2.0.0-beta.20",
Expand Down

0 comments on commit 73324aa

Please sign in to comment.