mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Merge pull request #12543 from wonderful-panda/fix-12536
tsserver: get candidates from <K extends keyof Foo> (fix #12536)
This commit is contained in:
commit
6418c2f9bb
@ -114,7 +114,8 @@ namespace ts {
|
||||
// we deliberately exclude augmentations
|
||||
// since we are only interested in declarations of the module itself
|
||||
return tryFindAmbientModule(moduleName, /*withAugmentations*/ false);
|
||||
}
|
||||
},
|
||||
getApparentType
|
||||
};
|
||||
|
||||
const tupleTypes: GenericType[] = [];
|
||||
|
||||
@ -2372,6 +2372,7 @@ namespace ts {
|
||||
getAmbientModules(): Symbol[];
|
||||
|
||||
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
||||
getApparentType(type: Type): Type;
|
||||
|
||||
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol;
|
||||
|
||||
|
||||
@ -244,6 +244,9 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
function addStringLiteralCompletionsFromType(type: Type, result: CompletionEntry[]): void {
|
||||
if (type && type.flags & TypeFlags.TypeParameter) {
|
||||
type = typeChecker.getApparentType(type);
|
||||
}
|
||||
if (!type) {
|
||||
return;
|
||||
}
|
||||
|
||||
15
tests/cases/fourslash/completionForStringLiteral5.ts
Normal file
15
tests/cases/fourslash/completionForStringLiteral5.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface Foo {
|
||||
//// foo: string;
|
||||
//// bar: string;
|
||||
////}
|
||||
////
|
||||
////function f<K extends keyof Foo>(a: K) { };
|
||||
////f("/*1*/
|
||||
|
||||
goTo.marker('1');
|
||||
verify.completionListContains("foo");
|
||||
verify.completionListContains("bar");
|
||||
verify.memberListCount(2);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user