Merge pull request #12543 from wonderful-panda/fix-12536

tsserver: get candidates from <K extends keyof Foo> (fix #12536)
This commit is contained in:
Mohamed Hegazy 2016-12-30 13:23:07 -08:00 committed by GitHub
commit 6418c2f9bb
4 changed files with 21 additions and 1 deletions

View File

@ -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[] = [];

View File

@ -2372,6 +2372,7 @@ namespace ts {
getAmbientModules(): Symbol[];
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
getApparentType(type: Type): Type;
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol;

View File

@ -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;
}

View 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);