Skip to content

Commit 9ba3656

Browse files
authored
Port "Provide string completions for in keyword checks" (#1803)
1 parent 2a336d0 commit 9ba3656

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

internal/ls/string_completions.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,22 @@ func (l *LanguageService) getStringLiteralCompletionEntries(
375375
hasIndexSignature: false,
376376
},
377377
}
378+
case ast.KindBinaryExpression:
379+
if parent.AsBinaryExpression().OperatorToken.Kind == ast.KindInKeyword {
380+
t := typeChecker.GetTypeAtLocation(parent.AsBinaryExpression().Right)
381+
properties := getPropertiesForCompletion(t, typeChecker)
382+
return &stringLiteralCompletions{
383+
fromProperties: &completionsFromProperties{
384+
symbols: core.Filter(properties, func(s *ast.Symbol) bool {
385+
return s.ValueDeclaration == nil || !ast.IsPrivateIdentifierClassElementDeclaration(s.ValueDeclaration)
386+
}),
387+
hasIndexSignature: false,
388+
},
389+
}
390+
}
391+
return &stringLiteralCompletions{
392+
fromTypes: fromContextualType(checker.ContextFlagsNone, node, typeChecker),
393+
}
378394
default:
379395
result := fromContextualType(checker.ContextFlagsCompletions, node, typeChecker)
380396
if result != nil {

0 commit comments

Comments
 (0)