-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(scope-manager): fix incorrect handling of class decorators and cl…
…ass method default params (#2943) Fixes #2941 Fixes #2942 This was a regression introduced by #2751
- Loading branch information
1 parent
60c5dcd
commit e1eac83
Showing
7 changed files
with
375 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/scope-manager/tests/fixtures/class/declaration/method-param-default.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// https://github.com/typescript-eslint/typescript-eslint/issues/2941 | ||
|
||
class A { | ||
constructor(printName) { | ||
this.printName = printName; | ||
} | ||
|
||
openPort(printerName = this.printerName) { | ||
this.tscOcx.ActiveXopenport(printerName); | ||
|
||
return this; | ||
} | ||
} |
164 changes: 164 additions & 0 deletions
164
packages/scope-manager/tests/fixtures/class/declaration/method-param-default.ts.shot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`class declaration method-param-default 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
Variable$2 { | ||
defs: Array [ | ||
ClassNameDefinition$1 { | ||
name: Identifier<"A">, | ||
node: ClassDeclaration$1, | ||
}, | ||
], | ||
name: "A", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
Variable$3 { | ||
defs: Array [ | ||
ClassNameDefinition$2 { | ||
name: Identifier<"A">, | ||
node: ClassDeclaration$1, | ||
}, | ||
], | ||
name: "A", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
Variable$4 { | ||
defs: Array [], | ||
name: "arguments", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
Variable$5 { | ||
defs: Array [ | ||
ParameterDefinition$3 { | ||
name: Identifier<"printName">, | ||
node: FunctionExpression$2, | ||
}, | ||
], | ||
name: "printName", | ||
references: Array [ | ||
Reference$1 { | ||
identifier: Identifier<"printName">, | ||
isRead: true, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: false, | ||
resolved: Variable$5, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: false, | ||
}, | ||
Variable$6 { | ||
defs: Array [], | ||
name: "arguments", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
Variable$7 { | ||
defs: Array [ | ||
ParameterDefinition$4 { | ||
name: Identifier<"printerName">, | ||
node: FunctionExpression$3, | ||
}, | ||
], | ||
name: "printerName", | ||
references: Array [ | ||
Reference$2 { | ||
identifier: Identifier<"printerName">, | ||
init: true, | ||
isRead: false, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: true, | ||
resolved: Variable$7, | ||
writeExpr: MemberExpression$4, | ||
}, | ||
Reference$3 { | ||
identifier: Identifier<"printerName">, | ||
isRead: true, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: false, | ||
resolved: Variable$7, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: false, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$5, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map { | ||
"const" => ImplicitGlobalConstTypeVariable, | ||
"A" => Variable$2, | ||
}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
Variable$2, | ||
], | ||
}, | ||
ClassScope$2 { | ||
block: ClassDeclaration$1, | ||
isStrict: true, | ||
references: Array [], | ||
set: Map { | ||
"A" => Variable$3, | ||
}, | ||
type: "class", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$3, | ||
], | ||
}, | ||
FunctionScope$3 { | ||
block: FunctionExpression$2, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$1, | ||
], | ||
set: Map { | ||
"arguments" => Variable$4, | ||
"printName" => Variable$5, | ||
}, | ||
type: "function", | ||
upper: ClassScope$2, | ||
variables: Array [ | ||
Variable$4, | ||
Variable$5, | ||
], | ||
}, | ||
FunctionScope$4 { | ||
block: FunctionExpression$3, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$2, | ||
Reference$3, | ||
], | ||
set: Map { | ||
"arguments" => Variable$6, | ||
"printerName" => Variable$7, | ||
}, | ||
type: "function", | ||
upper: ClassScope$2, | ||
variables: Array [ | ||
Variable$6, | ||
Variable$7, | ||
], | ||
}, | ||
], | ||
} | ||
`; |
10 changes: 10 additions & 0 deletions
10
packages/scope-manager/tests/fixtures/decorators/class-deco-with-object-param.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// https://github.com/typescript-eslint/typescript-eslint/issues/2942 | ||
|
||
declare function deco(...param: any): (...param: any) => any; | ||
|
||
@deco({ | ||
components: { | ||
val: true, | ||
}, | ||
}) | ||
class Foo {} |
Oops, something went wrong.