@@ -281,11 +281,13 @@ func (l *LanguageService) getStringLiteralCompletionEntries(
281281 fromProperties : stringLiteralCompletionsForObjectLiteral (typeChecker , parent .Parent ),
282282 }
283283 }
284- result := fromContextualType (checker .ContextFlagsCompletions , node , typeChecker )
285- if result != nil {
286- return & stringLiteralCompletions {
287- fromTypes : result ,
288- }
284+ if ast .FindAncestor (parent .Parent , ast .IsCallLikeExpression ) != nil {
285+ uniques := & collections.Set [string ]{}
286+ stringLiteralTypes := append (
287+ getStringLiteralTypes (typeChecker .GetContextualType (node , checker .ContextFlagsNone ), uniques , typeChecker ),
288+ getStringLiteralTypes (typeChecker .GetContextualType (node , checker .ContextFlagsCompletions ), uniques , typeChecker )... ,
289+ )
290+ return toStringLiteralCompletionsFromTypes (stringLiteralTypes )
289291 }
290292 return & stringLiteralCompletions {
291293 fromTypes : fromContextualType (checker .ContextFlagsNone , node , typeChecker ),
@@ -421,7 +423,10 @@ func (l *LanguageService) getStringLiteralCompletionEntries(
421423func fromContextualType (contextFlags checker.ContextFlags , node * ast.Node , typeChecker * checker.Checker ) * completionsFromTypes {
422424 // Get completion for string literal from string literal type
423425 // i.e. var x: "hi" | "hello" = "/*completion position*/"
424- types := getStringLiteralTypes (getContextualTypeFromParent (node , typeChecker , contextFlags ), nil , typeChecker )
426+ return toCompletionsFromTypes (getStringLiteralTypes (getContextualTypeFromParent (node , typeChecker , contextFlags ), nil , typeChecker ))
427+ }
428+
429+ func toCompletionsFromTypes (types []* checker.StringLiteralType ) * completionsFromTypes {
425430 if len (types ) == 0 {
426431 return nil
427432 }
@@ -431,6 +436,16 @@ func fromContextualType(contextFlags checker.ContextFlags, node *ast.Node, typeC
431436 }
432437}
433438
439+ func toStringLiteralCompletionsFromTypes (types []* checker.StringLiteralType ) * stringLiteralCompletions {
440+ result := toCompletionsFromTypes (types )
441+ if result == nil {
442+ return nil
443+ }
444+ return & stringLiteralCompletions {
445+ fromTypes : result ,
446+ }
447+ }
448+
434449func fromUnionableLiteralType (
435450 grandparent * ast.Node ,
436451 parent * ast.Node ,
0 commit comments