diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 22dec25324d..ef68b15ca94 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -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[] = [];
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index 9f9a2f69d6d..2fa41b4e62e 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -2372,6 +2372,7 @@ namespace ts {
getAmbientModules(): Symbol[];
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
+ getApparentType(type: Type): Type;
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol;
diff --git a/src/services/completions.ts b/src/services/completions.ts
index b710aa8cd78..f0daa696474 100644
--- a/src/services/completions.ts
+++ b/src/services/completions.ts
@@ -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;
}
diff --git a/tests/cases/fourslash/completionForStringLiteral5.ts b/tests/cases/fourslash/completionForStringLiteral5.ts
new file mode 100644
index 00000000000..3752734d913
--- /dev/null
+++ b/tests/cases/fourslash/completionForStringLiteral5.ts
@@ -0,0 +1,15 @@
+///
+
+////interface Foo {
+//// foo: string;
+//// bar: string;
+////}
+////
+////function f(a: K) { };
+////f("/*1*/
+
+goTo.marker('1');
+verify.completionListContains("foo");
+verify.completionListContains("bar");
+verify.memberListCount(2);
+