mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Retry string completions from the inferred type by default (#53481)
This commit is contained in:
@@ -440,7 +440,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);
|
||||
}
|
||||
|
||||
function fromContextualType(contextFlags: ContextFlags = ContextFlags.Completions): StringLiteralCompletionsFromTypes | undefined {
|
||||
|
||||
@@ -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"] });
|
||||
Reference in New Issue
Block a user