Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/stringCompletions.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -439,7 +439,7 @@ function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringL
const literals = contextualTypes.types.filter(literal => !tracker.hasValue(literal.value));
return { kind: StringLiteralCompletionKind.Types, types: literals, isNewIdentifier: false };
default:
return fromContextualType();
return fromContextualType() || fromContextualType(ContextFlags.None);

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a more conservative approach would be to do this:

caseSyntaxKind.ArrayLiteralExpression:
returnfromContextualType()||fromContextualType(ContextFlags.None);
default:
returnfromContextualType();

i went for a broad fix~ but perhaps some node types should not be subjects for those retries?

}

function fromContextualType(contextFlags: ContextFlags = ContextFlags.Completions): StringLiteralCompletionsFromTypes | undefined {
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
/// <reference path="fourslash.ts" />

//// declare function test<T>(a: {
//// [K in keyof T]: {
//// b?: (keyof T)[];
//// };
//// }): void;
////
//// test({
//// foo: {},
//// bar: {
//// b: ["/*ts*/"],
//// },
//// });

verify.completions({ marker: ["ts"], exact: ["foo", "bar"] });