mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Merge pull request #19204 from Kingwl/fix-completions-with-template-literal-type
fix completions for string literal types with template string (#19162)
This commit is contained in:
commit
89b5d8cb14
@ -238,7 +238,7 @@ namespace ts.Completions {
|
||||
|
||||
function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number, typeChecker: TypeChecker, compilerOptions: CompilerOptions, host: LanguageServiceHost, log: Log): CompletionInfo | undefined {
|
||||
const node = findPrecedingToken(position, sourceFile);
|
||||
if (!node || node.kind !== SyntaxKind.StringLiteral) {
|
||||
if (!node || (node.kind !== SyntaxKind.StringLiteral && node.kind !== SyntaxKind.NoSubstitutionTemplateLiteral)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ namespace ts.Completions {
|
||||
|
||||
// Get completion for string literal from string literal type
|
||||
// i.e. var x: "hi" | "hello" = "/*completion position*/"
|
||||
return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(<StringLiteral>node), typeChecker);
|
||||
return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(<LiteralExpression>node), typeChecker);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////let count: 'one' | 'two';
|
||||
////count = `/**/`
|
||||
|
||||
goTo.marker();
|
||||
verify.completionListContains('one');
|
||||
verify.completionListContains('two');
|
||||
Loading…
x
Reference in New Issue
Block a user