Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(typescript-estree): fix decorator regression for pre TS4.8#5574

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 3 commits intomainfrom5571-decorator-regression
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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",
Expand Down
12 changes: 4 additions & 8 deletionspackages/typescript-estree/src/convert.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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;
Expand Down
2 changes: 1 addition & 1 deletionpackages/typescript-estree/src/getModifiers.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
);
}
11 changes: 10 additions & 1 deletionpatches/typescript+4.8.2.patch
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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 {
Expand DownExpand Up@@ -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<Decorator> | 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.
2 changes: 1 addition & 1 deletionyarn.lock
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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==
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp