File tree 6 files changed +24
-3
lines changed 6 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -3193,7 +3193,8 @@ namespace ts {
3193
3193
export type AnyValidImportOrReExport =
3194
3194
| ( ImportDeclaration | ExportDeclaration ) & { moduleSpecifier : StringLiteral }
3195
3195
| ImportEqualsDeclaration & { moduleReference : ExternalModuleReference & { expression : StringLiteral } }
3196
- | RequireOrImportCall ;
3196
+ | RequireOrImportCall
3197
+ | ImportTypeNode & { argument : LiteralType } ;
3197
3198
3198
3199
/* @internal */
3199
3200
export type RequireOrImportCall = CallExpression & { arguments : [ StringLiteralLike ] } ;
Original file line number Diff line number Diff line change @@ -1710,8 +1710,10 @@ namespace ts {
1710
1710
return ( node . parent as ExternalModuleReference ) . parent as AnyValidImportOrReExport ;
1711
1711
case SyntaxKind . CallExpression :
1712
1712
return node . parent as AnyValidImportOrReExport ;
1713
+ case SyntaxKind . LiteralType :
1714
+ return cast ( node . parent . parent , isImportTypeNode ) as ImportTypeNode & { argument : LiteralType } ;
1713
1715
default :
1714
- return Debug . fail ( Debug . showSyntaxKind ( node ) ) ;
1716
+ return Debug . fail ( Debug . showSyntaxKind ( node . parent ) ) ;
1715
1717
}
1716
1718
}
1717
1719
@@ -4926,6 +4928,10 @@ namespace ts {
4926
4928
return node . kind === SyntaxKind . LiteralType ;
4927
4929
}
4928
4930
4931
+ export function isImportTypeNode ( node : Node ) : node is ImportTypeNode {
4932
+ return node . kind === SyntaxKind . ImportType ;
4933
+ }
4934
+
4929
4935
// Binding patterns
4930
4936
4931
4937
export function isObjectBindingPattern ( node : Node ) : node is ObjectBindingPattern {
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ namespace ts.FindAllReferences {
33
33
interface AmbientModuleDeclaration extends ModuleDeclaration { body ?: ModuleBlock ; }
34
34
type SourceFileLike = SourceFile | AmbientModuleDeclaration ;
35
35
// Identifier for the case of `const x = require("y")`.
36
- type Importer = AnyImportOrReExport | Identifier ;
36
+ type Importer = AnyImportOrReExport | ImportTypeNode | Identifier ;
37
37
type ImporterOrCallExpression = Importer | CallExpression ;
38
38
39
39
/** Returns import statements that directly reference the exporting module, and a list of files that may access the module through a namespace. */
@@ -215,6 +215,10 @@ namespace ts.FindAllReferences {
215
215
return ;
216
216
}
217
217
218
+ if ( decl . kind === SyntaxKind . ImportType ) {
219
+ return ;
220
+ }
221
+
218
222
// Ignore if there's a grammar error
219
223
if ( decl . moduleSpecifier . kind !== SyntaxKind . StringLiteral ) {
220
224
return ;
Original file line number Diff line number Diff line change @@ -3169,6 +3169,7 @@ declare namespace ts {
3169
3169
function isIndexedAccessTypeNode ( node : Node ) : node is IndexedAccessTypeNode ;
3170
3170
function isMappedTypeNode ( node : Node ) : node is MappedTypeNode ;
3171
3171
function isLiteralTypeNode ( node : Node ) : node is LiteralTypeNode ;
3172
+ function isImportTypeNode ( node : Node ) : node is ImportTypeNode ;
3172
3173
function isObjectBindingPattern ( node : Node ) : node is ObjectBindingPattern ;
3173
3174
function isArrayBindingPattern ( node : Node ) : node is ArrayBindingPattern ;
3174
3175
function isBindingElement ( node : Node ) : node is BindingElement ;
Original file line number Diff line number Diff line change @@ -3169,6 +3169,7 @@ declare namespace ts {
3169
3169
function isIndexedAccessTypeNode ( node : Node ) : node is IndexedAccessTypeNode ;
3170
3170
function isMappedTypeNode ( node : Node ) : node is MappedTypeNode ;
3171
3171
function isLiteralTypeNode ( node : Node ) : node is LiteralTypeNode ;
3172
+ function isImportTypeNode ( node : Node ) : node is ImportTypeNode ;
3172
3173
function isObjectBindingPattern ( node : Node ) : node is ObjectBindingPattern ;
3173
3174
function isArrayBindingPattern ( node : Node ) : node is ArrayBindingPattern ;
3174
3175
function isBindingElement ( node : Node ) : node is BindingElement ;
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ // @Filename : /a.ts
4
+ ////export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0;
5
+ ////declare const a: typeof import("./a");
6
+ ////a.[|x|];
7
+
8
+ verify . singleReferenceGroup ( "const x: 0" ) ;
You can’t perform that action at this time.
0 commit comments