@@ -33,6 +33,7 @@ import {
33
33
endsWith ,
34
34
ensureTrailingDirectorySeparator ,
35
35
equateStringsCaseSensitive ,
36
+ escapeString ,
36
37
Extension ,
37
38
fileExtensionIsOneOf ,
38
39
filter ,
@@ -64,6 +65,7 @@ import {
64
65
getSupportedExtensions ,
65
66
getSupportedExtensionsWithJsonIfResolveJsonModule ,
66
67
getTextOfJsxAttributeName ,
68
+ getTextOfNode ,
67
69
getTokenAtPosition ,
68
70
hasIndexSignature ,
69
71
hasProperty ,
@@ -263,8 +265,13 @@ function convertStringLiteralCompletions(
263
265
return { isGlobalCompletion : false , isMemberCompletion : true , isNewIdentifierLocation : completion . hasIndexSignature , optionalReplacementSpan, entries } ;
264
266
}
265
267
case StringLiteralCompletionKind . Types : {
268
+ const quoteChar = contextToken . kind === SyntaxKind . NoSubstitutionTemplateLiteral
269
+ ? CharacterCodes . backtick
270
+ : startsWith ( getTextOfNode ( contextToken ) , "'" )
271
+ ? CharacterCodes . singleQuote
272
+ : CharacterCodes . doubleQuote ;
266
273
const entries = completion . types . map ( type => ( {
267
- name : type . value ,
274
+ name : escapeString ( type . value , quoteChar ) ,
268
275
kindModifiers : ScriptElementKindModifier . none ,
269
276
kind : ScriptElementKind . string ,
270
277
sortText : SortText . LocationPriority ,
0 commit comments