findAllReferences: Type parameter is not globally visible (#16419)
* findAllReferences: Type parameter is not globally visible * Add test for merged interface * Clean up comment
This commit is contained in:
parent
39e0cc61a7
commit
e73d58e21c
|
@ -652,10 +652,15 @@ namespace ts.FindAllReferences.Core {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the symbol has a parent, it's globally visible.
|
/*
|
||||||
// Unless that parent is an external module, then we should only search in the module (and recurse on the export later).
|
If the symbol has a parent, it's globally visible unless:
|
||||||
// But if the parent is a module that has `export as namespace`, then the symbol *is* globally visible.
|
- It's a private property (handled above).
|
||||||
if (parent && !((parent.flags & SymbolFlags.Module) && isExternalModuleSymbol(parent) && !parent.globalExports)) {
|
- It's a type parameter.
|
||||||
|
- The parent is an external module: then we should only search in the module (and recurse on the export later).
|
||||||
|
- But if the parent has `export as namespace`, the symbol is globally visible through that namespace.
|
||||||
|
*/
|
||||||
|
const exposedByParent = parent && !(symbol.flags & SymbolFlags.TypeParameter);
|
||||||
|
if (exposedByParent && !((parent.flags & SymbolFlags.Module) && isExternalModuleSymbol(parent) && !parent.globalExports)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,7 +687,7 @@ namespace ts.FindAllReferences.Core {
|
||||||
// declare module "a" { export type T = number; }
|
// declare module "a" { export type T = number; }
|
||||||
// declare module "b" { import { T } from "a"; export const x: T; }
|
// declare module "b" { import { T } from "a"; export const x: T; }
|
||||||
// So we must search the whole source file. (Because we will mark the source file as seen, we we won't return to it when searching for imports.)
|
// So we must search the whole source file. (Because we will mark the source file as seen, we we won't return to it when searching for imports.)
|
||||||
return parent ? scope.getSourceFile() : scope;
|
return exposedByParent ? scope.getSourceFile() : scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): number[] {
|
function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): number[] {
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
/// <reference path='fourslash.ts' />
|
||||||
|
|
||||||
|
////interface I<[|{| "isWriteAccess": true, "isDefinition": true |}T|]> { a: [|T|] }
|
||||||
|
////interface I<[|{| "isWriteAccess": true, "isDefinition": true |}T|]> { b: [|T|] }
|
||||||
|
|
||||||
|
verify.singleReferenceGroup("(type parameter) T in I<T>");
|
Loading…
Reference in a new issue