Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scope-manager): support TS4.5 import/export specifier kind
- Loading branch information
1 parent
9f58eab
commit 8efa5c8
Showing
21 changed files
with
342 additions
and
34 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//// @sourceType = module | ||
|
||
const T = 1; // unreferenced | ||
type T = 1; | ||
export default T; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//// @sourceType = module | ||
|
||
const T = 1; // unreferenced | ||
type T = 1; | ||
export { type T }; |
75 changes: 75 additions & 0 deletions
75
packages/scope-manager/tests/fixtures/export/type-inline.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,75 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`export type-inline 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
Variable$2 { | ||
defs: Array [ | ||
VariableDefinition$1 { | ||
name: Identifier<"T">, | ||
node: VariableDeclarator$1, | ||
}, | ||
TypeDefinition$2 { | ||
name: Identifier<"T">, | ||
node: TSTypeAliasDeclaration$2, | ||
}, | ||
], | ||
name: "T", | ||
references: Array [ | ||
Reference$1 { | ||
identifier: Identifier<"T">, | ||
init: true, | ||
isRead: false, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: true, | ||
resolved: Variable$2, | ||
writeExpr: Literal$3, | ||
}, | ||
Reference$2 { | ||
identifier: Identifier<"T">, | ||
isRead: true, | ||
isTypeReference: true, | ||
isValueReference: false, | ||
isWrite: false, | ||
resolved: Variable$2, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$4, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map { | ||
"const" => ImplicitGlobalConstTypeVariable, | ||
}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
], | ||
}, | ||
ModuleScope$2 { | ||
block: Program$4, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$1, | ||
Reference$2, | ||
], | ||
set: Map { | ||
"T" => Variable$2, | ||
}, | ||
type: "module", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$2, | ||
], | ||
}, | ||
], | ||
} | ||
`; |
5 changes: 5 additions & 0 deletions
5
packages/scope-manager/tests/fixtures/import/type-inline-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; |
74 changes: 74 additions & 0 deletions
74
packages/scope-manager/tests/fixtures/import/type-inline-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,74 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`import type-inline-value 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
Variable$2 { | ||
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$2, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
Variable$3 { | ||
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 { | ||
"const" => ImplicitGlobalConstTypeVariable, | ||
}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
], | ||
}, | ||
ModuleScope$2 { | ||
block: Program$3, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$1, | ||
], | ||
set: Map { | ||
"foo" => Variable$2, | ||
"T" => Variable$3, | ||
}, | ||
type: "module", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$2, | ||
Variable$3, | ||
], | ||
}, | ||
], | ||
} | ||
`; |
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,6 @@ | ||
//// @sourceType = module | ||
|
||
import { type T } from 'foo'; | ||
|
||
type Ref = T; | ||
const unresolved = T; |
109 changes: 109 additions & 0 deletions
109
packages/scope-manager/tests/fixtures/import/type-inline.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,109 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`import type-inline 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
Variable$2 { | ||
defs: Array [ | ||
ImportBindingDefinition$1 { | ||
name: Identifier<"T">, | ||
node: ImportSpecifier$1, | ||
}, | ||
], | ||
name: "T", | ||
references: Array [ | ||
Reference$1 { | ||
identifier: Identifier<"T">, | ||
isRead: true, | ||
isTypeReference: true, | ||
isValueReference: false, | ||
isWrite: false, | ||
resolved: Variable$2, | ||
}, | ||
Reference$3 { | ||
identifier: Identifier<"T">, | ||
isRead: true, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: false, | ||
resolved: Variable$2, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
Variable$3 { | ||
defs: Array [ | ||
TypeDefinition$2 { | ||
name: Identifier<"Ref">, | ||
node: TSTypeAliasDeclaration$2, | ||
}, | ||
], | ||
name: "Ref", | ||
references: Array [], | ||
isValueVariable: false, | ||
isTypeVariable: true, | ||
}, | ||
Variable$4 { | ||
defs: Array [ | ||
VariableDefinition$3 { | ||
name: Identifier<"unresolved">, | ||
node: VariableDeclarator$3, | ||
}, | ||
], | ||
name: "unresolved", | ||
references: Array [ | ||
Reference$2 { | ||
identifier: Identifier<"unresolved">, | ||
init: true, | ||
isRead: false, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: true, | ||
resolved: Variable$4, | ||
writeExpr: Identifier<"T">, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: false, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$4, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map { | ||
"const" => ImplicitGlobalConstTypeVariable, | ||
}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
], | ||
}, | ||
ModuleScope$2 { | ||
block: Program$4, | ||
isStrict: true, | ||
references: Array [ | ||
Reference$1, | ||
Reference$2, | ||
Reference$3, | ||
], | ||
set: Map { | ||
"T" => Variable$2, | ||
"Ref" => Variable$3, | ||
"unresolved" => Variable$4, | ||
}, | ||
type: "module", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$2, | ||
Variable$3, | ||
Variable$4, | ||
], | ||
}, | ||
], | ||
} | ||
`; |
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
import type { T } from 'foo'; | ||
|
||
type Ref = T; | ||
const unresovled = T; | ||
const unresolved = T; |
Oops, something went wrong.