Don't treat interfaces as implementations

...even if they're in ambient contexts.  Same for type aliases.
This commit is contained in:
Andrew Casey 2019-01-17 14:45:40 -08:00
parent 9bd23652ef
commit 737fda928c
3 changed files with 26 additions and 1 deletions

View File

@ -1682,7 +1682,8 @@ namespace ts.FindAllReferences.Core {
function isImplementation(node: Node): boolean {
return !!(node.flags & NodeFlags.Ambient)
|| (isVariableLike(node) ? hasInitializer(node)
? !(isInterfaceDeclaration(node) || isTypeAliasDeclaration(node))
: (isVariableLike(node) ? hasInitializer(node)
: isFunctionLikeDeclaration(node) ? !!node.body
: isClassLike(node) || isModuleOrEnumDeclaration(node));
}

View File

@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>
// Should go to object literals within cast expressions when invoked on interface
// @Filename: def.d.ts
//// export interface Interface { P: number }
// @Filename: ref.ts
//// import { Interface } from "./def";
//// const c: I/*ref*/nterface = [|{ P: 2 }|];
verify.allRangesAppearInImplementationList("ref");

View File

@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>
// Should go to object literals within cast expressions when invoked on interface
// @Filename: def.d.ts
//// export type TypeAlias = { P: number }
// @Filename: ref.ts
//// import { TypeAlias } from "./def";
//// const c: T/*ref*/ypeAlias = [|{ P: 2 }|];
verify.allRangesAppearInImplementationList("ref");