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): treat type imports as both values and types (#2494)
Fixes #2453
- Loading branch information
1 parent
a40f54c
commit 916e95a
Showing
9 changed files
with
174 additions
and
37 deletions.
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
5 changes: 5 additions & 0 deletions
5
packages/scope-manager/tests/fixtures/import/type-default-value.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,5 @@ | ||
//// @sourceType = module | ||
|
||
import type foo from 'foo'; | ||
|
||
type T = typeof foo; |
69 changes: 69 additions & 0 deletions
69
packages/scope-manager/tests/fixtures/import/type-default-value.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,69 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`import type-default-value 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
Variable$1 { | ||
defs: Array [ | ||
ImportBindingDefinition$1 { | ||
name: Identifier<"foo">, | ||
node: ImportDefaultSpecifier$1, | ||
}, | ||
], | ||
name: "foo", | ||
references: Array [ | ||
Reference$1 { | ||
identifier: Identifier<"foo">, | ||
isRead: true, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: false, | ||
resolved: Variable$1, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
Variable$2 { | ||
defs: Array [ | ||
TypeDefinition$2 { | ||
name: Identifier<"T">, | ||
node: TSTypeAliasDeclaration$2, | ||
}, | ||
], | ||
name: "T", | ||
references: Array [], | ||
isValueVariable: false, | ||
isTypeVariable: true, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$3, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map {}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [], | ||
}, | ||
ModuleScope$2 { | ||
block: Program$3, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$1, | ||
], | ||
set: Map { | ||
"foo" => Variable$1, | ||
"T" => Variable$2, | ||
}, | ||
type: "module", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$1, | ||
Variable$2, | ||
], | ||
}, | ||
], | ||
} | ||
`; |
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
5 changes: 5 additions & 0 deletions
5
packages/scope-manager/tests/fixtures/import/type-named-value.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,5 @@ | ||
//// @sourceType = module | ||
|
||
import type { foo } from 'foo'; | ||
|
||
type T = typeof foo; |
69 changes: 69 additions & 0 deletions
69
packages/scope-manager/tests/fixtures/import/type-named-value.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,69 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`import type-named-value 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
Variable$1 { | ||
defs: Array [ | ||
ImportBindingDefinition$1 { | ||
name: Identifier<"foo">, | ||
node: ImportSpecifier$1, | ||
}, | ||
], | ||
name: "foo", | ||
references: Array [ | ||
Reference$1 { | ||
identifier: Identifier<"foo">, | ||
isRead: true, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: false, | ||
resolved: Variable$1, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
Variable$2 { | ||
defs: Array [ | ||
TypeDefinition$2 { | ||
name: Identifier<"T">, | ||
node: TSTypeAliasDeclaration$2, | ||
}, | ||
], | ||
name: "T", | ||
references: Array [], | ||
isValueVariable: false, | ||
isTypeVariable: true, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$3, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map {}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [], | ||
}, | ||
ModuleScope$2 { | ||
block: Program$3, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$1, | ||
], | ||
set: Map { | ||
"foo" => Variable$1, | ||
"T" => Variable$2, | ||
}, | ||
type: "module", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$1, | ||
Variable$2, | ||
], | ||
}, | ||
], | ||
} | ||
`; |
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