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): support rest function type parameters
Fixes #2449
- Loading branch information
1 parent
cee9be7
commit 33fb178
Showing
8 changed files
with
310 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
1 change: 1 addition & 0 deletions
1
packages/scope-manager/tests/fixtures/type-declaration/function/params/array-pattern.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 @@ | ||
type Fn<A extends unknown[]> = ([a]: A) => unknown; |
96 changes: 96 additions & 0 deletions
96
packages/scope-manager/tests/fixtures/type-declaration/function/params/array-pattern.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,96 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`type-declaration function params array-pattern 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
Variable$1 { | ||
defs: Array [ | ||
TypeDefinition$1 { | ||
name: Identifier<"Fn">, | ||
node: TSTypeAliasDeclaration$1, | ||
}, | ||
], | ||
name: "Fn", | ||
references: Array [], | ||
isValueVariable: false, | ||
isTypeVariable: true, | ||
}, | ||
Variable$2 { | ||
defs: Array [ | ||
TypeDefinition$2 { | ||
name: Identifier<"A">, | ||
node: TSTypeParameter$2, | ||
}, | ||
], | ||
name: "A", | ||
references: Array [ | ||
Reference$1 { | ||
identifier: Identifier<"A">, | ||
isRead: true, | ||
isTypeReference: true, | ||
isValueReference: false, | ||
isWrite: false, | ||
resolved: Variable$2, | ||
}, | ||
], | ||
isValueVariable: false, | ||
isTypeVariable: true, | ||
}, | ||
Variable$3 { | ||
defs: Array [ | ||
ParameterDefinition$3 { | ||
name: Identifier<"a">, | ||
node: TSFunctionType$3, | ||
}, | ||
], | ||
name: "a", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: false, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$4, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map { | ||
"Fn" => Variable$1, | ||
}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [ | ||
Variable$1, | ||
], | ||
}, | ||
TypeScope$2 { | ||
block: TSTypeAliasDeclaration$1, | ||
isStrict: true, | ||
references: Array [], | ||
set: Map { | ||
"A" => Variable$2, | ||
}, | ||
type: "type", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$2, | ||
], | ||
}, | ||
FunctionTypeScope$3 { | ||
block: TSFunctionType$3, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$1, | ||
], | ||
set: Map { | ||
"a" => Variable$3, | ||
}, | ||
type: "functionType", | ||
upper: TypeScope$2, | ||
variables: Array [ | ||
Variable$3, | ||
], | ||
}, | ||
], | ||
} | ||
`; |
1 change: 1 addition & 0 deletions
1
packages/scope-manager/tests/fixtures/type-declaration/function/params/object-pattern.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 @@ | ||
type Fn<A extends { a: string }> = ({ a }: A) => unknown; |
96 changes: 96 additions & 0 deletions
96
...ages/scope-manager/tests/fixtures/type-declaration/function/params/object-pattern.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,96 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`type-declaration function params object-pattern 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
Variable$1 { | ||
defs: Array [ | ||
TypeDefinition$1 { | ||
name: Identifier<"Fn">, | ||
node: TSTypeAliasDeclaration$1, | ||
}, | ||
], | ||
name: "Fn", | ||
references: Array [], | ||
isValueVariable: false, | ||
isTypeVariable: true, | ||
}, | ||
Variable$2 { | ||
defs: Array [ | ||
TypeDefinition$2 { | ||
name: Identifier<"A">, | ||
node: TSTypeParameter$2, | ||
}, | ||
], | ||
name: "A", | ||
references: Array [ | ||
Reference$1 { | ||
identifier: Identifier<"A">, | ||
isRead: true, | ||
isTypeReference: true, | ||
isValueReference: false, | ||
isWrite: false, | ||
resolved: Variable$2, | ||
}, | ||
], | ||
isValueVariable: false, | ||
isTypeVariable: true, | ||
}, | ||
Variable$3 { | ||
defs: Array [ | ||
ParameterDefinition$3 { | ||
name: Identifier<"a">, | ||
node: TSFunctionType$3, | ||
}, | ||
], | ||
name: "a", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: false, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$4, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map { | ||
"Fn" => Variable$1, | ||
}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [ | ||
Variable$1, | ||
], | ||
}, | ||
TypeScope$2 { | ||
block: TSTypeAliasDeclaration$1, | ||
isStrict: true, | ||
references: Array [], | ||
set: Map { | ||
"A" => Variable$2, | ||
}, | ||
type: "type", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$2, | ||
], | ||
}, | ||
FunctionTypeScope$3 { | ||
block: TSFunctionType$3, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$1, | ||
], | ||
set: Map { | ||
"a" => Variable$3, | ||
}, | ||
type: "functionType", | ||
upper: TypeScope$2, | ||
variables: Array [ | ||
Variable$3, | ||
], | ||
}, | ||
], | ||
} | ||
`; |
1 change: 1 addition & 0 deletions
1
packages/scope-manager/tests/fixtures/type-declaration/function/params/rest-element.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 @@ | ||
type Fn<A extends unknown[]> = (...a: A) => unknown; |
96 changes: 96 additions & 0 deletions
96
packages/scope-manager/tests/fixtures/type-declaration/function/params/rest-element.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,96 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`type-declaration function params rest-element 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
Variable$1 { | ||
defs: Array [ | ||
TypeDefinition$1 { | ||
name: Identifier<"Fn">, | ||
node: TSTypeAliasDeclaration$1, | ||
}, | ||
], | ||
name: "Fn", | ||
references: Array [], | ||
isValueVariable: false, | ||
isTypeVariable: true, | ||
}, | ||
Variable$2 { | ||
defs: Array [ | ||
TypeDefinition$2 { | ||
name: Identifier<"A">, | ||
node: TSTypeParameter$2, | ||
}, | ||
], | ||
name: "A", | ||
references: Array [ | ||
Reference$1 { | ||
identifier: Identifier<"A">, | ||
isRead: true, | ||
isTypeReference: true, | ||
isValueReference: false, | ||
isWrite: false, | ||
resolved: Variable$2, | ||
}, | ||
], | ||
isValueVariable: false, | ||
isTypeVariable: true, | ||
}, | ||
Variable$3 { | ||
defs: Array [ | ||
ParameterDefinition$3 { | ||
name: Identifier<"a">, | ||
node: TSFunctionType$3, | ||
}, | ||
], | ||
name: "a", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: false, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$4, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map { | ||
"Fn" => Variable$1, | ||
}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [ | ||
Variable$1, | ||
], | ||
}, | ||
TypeScope$2 { | ||
block: TSTypeAliasDeclaration$1, | ||
isStrict: true, | ||
references: Array [], | ||
set: Map { | ||
"A" => Variable$2, | ||
}, | ||
type: "type", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$2, | ||
], | ||
}, | ||
FunctionTypeScope$3 { | ||
block: TSFunctionType$3, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$1, | ||
], | ||
set: Map { | ||
"a" => Variable$3, | ||
}, | ||
type: "functionType", | ||
upper: TypeScope$2, | ||
variables: Array [ | ||
Variable$3, | ||
], | ||
}, | ||
], | ||
} | ||
`; |