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(scope-manager): visit params decorator before nest scope#10475

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
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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1116,6 +1116,58 @@ export const x = _Foo;
},
],
},
{
code: `
const command = (): ParameterDecorator => {
return () => {};
};

export class Foo {
bar(@command() command: string) {}
}
`,
errors: [
{
data: {
action: 'defined',
additional: '',
varName: 'command',
},
line: 7,
messageId: 'unusedVar',
},
],
},
{
code: `
declare const deco: () => ParameterDecorator;

export class Foo {
bar(@deco() deco, @deco() param) {}
}
`,
errors: [
{
column: 15,
data: {
action: 'defined',
additional: '',
varName: 'deco',
},
line: 5,
messageId: 'unusedVar',
},
{
data: {
action: 'defined',
additional: '',
varName: 'param',
},
line: 5,
messageId: 'unusedVar',
},
],
},
],

valid: [
Expand DownExpand Up@@ -2274,5 +2326,16 @@ export enum Foo {
`,
options: [{ reportUsedIgnorePattern: true, varsIgnorePattern: '_' }],
},
`
const command = (): ParameterDecorator => {
return () => {};
};

export class Foo {
bar(@command() command: string) {
console.log(command);
}
}
`,
],
});
5 changes: 4 additions & 1 deletionpackages/scope-manager/src/referencer/ClassVisitor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -115,6 +115,10 @@ class ClassVisitor extends Visitor {
this.#referencer.scopeManager.nestFunctionExpressionNameScope(node);
}

node.params.forEach(param => {
param.decorators.forEach(d => this.visit(d));
});

// Consider this function is in the MethodDefinition.
this.#referencer.scopeManager.nestFunctionScope(node, true);

Expand DownExpand Up@@ -205,7 +209,6 @@ class ClassVisitor extends Visitor {
{ processRightHandNodes: true },
);
this.visitFunctionParameterTypeAnnotation(param);
param.decorators.forEach(d => this.visit(d));
}

this.visitType(node.returnType);
Expand Down
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
function decorator() {}
class A {
foo(@decorator a, @decorator [b], @decorator { c }, @decorator d = 1) {}
foo(
@decorator a,
@decorator [b],
@decorator { c },
@decorator d = 1,
@decorator decorator,
@d decorator,
) {}
}
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp