From c1a5aa5e4039c5d3796a9cc795e64313713d5e0c Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 30 Aug 2022 18:43:34 +0930 Subject: [PATCH 1/3] fix(typescript-estree): fix decorator regression for pre TS4.8 --- packages/typescript-estree/src/convert.ts | 12 ++++-------- packages/typescript-estree/src/getModifiers.ts | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 4f69728b66a8..6c1963c04562 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1056,15 +1056,11 @@ export class Converter { /** * Semantically, decorators are not allowed on variable declarations, - * but the TypeScript compiler will parse them and produce a valid AST, - * so we handle them here too. + * Pre 4.8 TS would include them in the AST, so we did as well. + * However as of 4.8 TS no longer includes it (as it is, well, invalid). + * + * So for consistency across versions, we no longer include it either. */ - const decorators = getDecorators(node); - if (decorators) { - (result as any).decorators = decorators.map(el => - this.convertChild(el), - ); - } if (hasModifier(SyntaxKind.DeclareKeyword, node)) { result.declare = true; diff --git a/packages/typescript-estree/src/getModifiers.ts b/packages/typescript-estree/src/getModifiers.ts index 24f119f9e8ae..4b9f64d65015 100644 --- a/packages/typescript-estree/src/getModifiers.ts +++ b/packages/typescript-estree/src/getModifiers.ts @@ -47,6 +47,6 @@ export function getDecorators( return ( // eslint-disable-next-line deprecation/deprecation -- intentional fallback for older TS versions - node.modifiers?.filter(ts.isDecorator) + node.decorators?.filter(ts.isDecorator) ); } From 00a71f4b83e92c8870323e9ff72eebe38ec9bc2d Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 30 Aug 2022 18:56:36 +0930 Subject: [PATCH 2/3] patch the ts types --- patches/typescript+4.8.2.patch | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/patches/typescript+4.8.2.patch b/patches/typescript+4.8.2.patch index 42f28d47ece1..5fa1093b28e9 100644 --- a/patches/typescript+4.8.2.patch +++ b/patches/typescript+4.8.2.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/typescript/lib/typescript.d.ts b/node_modules/typescript/lib/typescript.d.ts -index 0fd60ae..b3610b8 100644 +index 0fd60ae..8bce90e 100644 --- a/node_modules/typescript/lib/typescript.d.ts +++ b/node_modules/typescript/lib/typescript.d.ts @@ -425,8 +425,8 @@ declare namespace ts { @@ -40,3 +40,12 @@ index 0fd60ae..b3610b8 100644 function canHaveDecorators(node: Node): node is HasDecorators; } declare namespace ts { +@@ -7924,7 +7936,7 @@ declare namespace ts { + * const decorators = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined; + * ``` + */ +- readonly decorators?: undefined; ++ readonly decorators?: NodeArray | undefined; + /** + * @deprecated `modifiers` has been removed from `Node` and moved to the `Node` subtypes that support them. + * Use `ts.canHaveModifiers()` to test whether a `Node` can have modifiers. From 3e43f2ea4d1ce28f6db08b0c44c8e5b45c135e4f Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 30 Aug 2022 19:41:40 +0930 Subject: [PATCH 3/3] touch package.json to bust netlify yarn cache --- package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f73d984d8bbc..0eff2a290d16 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "typescript": ">=3.3.1 <4.9.0" }, "resolutions": { - "typescript": "4.8.2", + "typescript": "~4.8.2", "@types/node": "^17.0.31", "pretty-format": "^28.1.0", "//": "Pin jest to v28 across the repo", diff --git a/yarn.lock b/yarn.lock index 14f3e9f6cc6e..5534c2bb2203 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14177,7 +14177,7 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@*, typescript@4.8.2, "typescript@>=3.3.1 <4.9.0", typescript@^4.5.3, typescript@next, typescript@~4.7.4: +typescript@*, "typescript@>=3.3.1 <4.9.0", typescript@^4.5.3, typescript@next, typescript@~4.7.4, typescript@~4.8.2: version "4.8.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.2.tgz#e3b33d5ccfb5914e4eeab6699cf208adee3fd790" integrity sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==