diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 77f35376da785..00dc170c2bb84 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8863,7 +8863,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } let expression: Expression | undefined; if (isSingleOrDoubleQuote(firstChar) && !(symbol.flags & SymbolFlags.EnumMember)) { - const literalText = stripQuotes(symbolName).replace(/\\./g, s => s.substring(1)); + const literalText = stripQuotes(symbolName.trim()).replace(/\\./g, s => s.substring(1)); context.approximateLength += literalText.length + 2; // "literalText" expression = factory.createStringLiteral(literalText, firstChar === CharacterCodes.singleQuote); } diff --git a/tests/cases/fourslash/hoverComputedPropertyWhitespace.ts b/tests/cases/fourslash/hoverComputedPropertyWhitespace.ts new file mode 100644 index 0000000000000..50f995ea22fe6 --- /dev/null +++ b/tests/cases/fourslash/hoverComputedPropertyWhitespace.ts @@ -0,0 +1,10 @@ +/// +//// interface Point { +//// ["x" ]: number; +//// } +//// +//// const p: Point = { ["x" ]: 42 }; +//// p["x"/*hover*/]; + +goTo.marker("hover"); +verify.quickInfoIs('(property) Point["x"]: number'); \ No newline at end of file