mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 01:43:59 -05:00
Fix bug: don't call addIndirectUser if we're not tracking indirect users (#22121)
This commit is contained in:
@@ -109,7 +109,9 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
else if (isDefaultImport(direct)) {
|
||||
const sourceFileLike = getSourceFileLikeForImportDeclaration(direct);
|
||||
addIndirectUser(sourceFileLike); // Add a check for indirect uses to handle synthetic default imports
|
||||
if (!isAvailableThroughGlobal) {
|
||||
addIndirectUser(sourceFileLike); // Add a check for indirect uses to handle synthetic default imports
|
||||
}
|
||||
directImports.push(direct);
|
||||
}
|
||||
else {
|
||||
@@ -651,8 +653,8 @@ namespace ts.FindAllReferences {
|
||||
if (parent.kind === SyntaxKind.SourceFile) {
|
||||
return parent as SourceFile;
|
||||
}
|
||||
Debug.assert(parent.kind === SyntaxKind.ModuleBlock && isAmbientModuleDeclaration(parent.parent));
|
||||
return parent.parent as AmbientModuleDeclaration;
|
||||
Debug.assert(parent.kind === SyntaxKind.ModuleBlock);
|
||||
return cast(parent.parent, isAmbientModuleDeclaration);
|
||||
}
|
||||
|
||||
function isAmbientModuleDeclaration(node: Node): node is AmbientModuleDeclaration {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
// @esModuleInterop: true
|
||||
|
||||
// @Filename: /abc.d.ts
|
||||
@@ -6,7 +8,7 @@
|
||||
////}
|
||||
|
||||
// @Filename: /b.ts
|
||||
////import * as a from "a";
|
||||
////import a from "a";
|
||||
////a.[|x|];
|
||||
|
||||
verify.rangesReferenceEachOther();
|
||||
15
tests/cases/fourslash/esModuleInteropFindAllReferences2.ts
Normal file
15
tests/cases/fourslash/esModuleInteropFindAllReferences2.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
// Tests that we don't always add an indirect user, which causes problems if the module is already available globally.
|
||||
|
||||
// @esModuleInterop: true
|
||||
|
||||
// @Filename: /a.d.ts
|
||||
////export as namespace abc;
|
||||
////export const [|x|]: number;
|
||||
|
||||
// @Filename: /b.ts
|
||||
////import a from "./a";
|
||||
////a.[|x|];
|
||||
|
||||
verify.rangesReferenceEachOther();
|
||||
Reference in New Issue
Block a user