Skip to content

Commit 979155c

Browse files
authored
Merge pull request #11 from joeywatts/private-name-server-display
Fix display of private names in the TS Language Server
2 parents b29c9cf + 3fc3756 commit 979155c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4171,7 +4171,10 @@ namespace ts {
41714171
context.flags ^= NodeBuilderFlags.InInitialEntityName;
41724172
}
41734173
let firstChar = symbolName.charCodeAt(0);
4174-
const canUsePropertyAccess = isIdentifierStart(firstChar, languageVersion);
4174+
const canUsePropertyAccess = firstChar === CharacterCodes.hash ?
4175+
symbolName.length > 1 && isIdentifierStart(symbolName.charCodeAt(1), languageVersion) :
4176+
isIdentifierStart(firstChar, languageVersion);
4177+
41754178
if (index === 0 || canUsePropertyAccess) {
41764179
const identifier = setEmitFlags(createIdentifier(symbolName, typeParameterNodes), EmitFlags.NoAsciiEscaping);
41774180
identifier.symbol = symbol;

tests/baselines/reference/privateNameField.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ class A {
33
>A : Symbol(A, Decl(privateNameField.ts, 0, 0))
44

55
#name: string;
6-
>#name : Symbol(A[#name], Decl(privateNameField.ts, 0, 9))
6+
>#name : Symbol(A.#name, Decl(privateNameField.ts, 0, 9))
77

88
constructor(name: string) {
99
>name : Symbol(name, Decl(privateNameField.ts, 2, 16))
1010

1111
this.#name = name;
12-
>this.#name : Symbol(A[#name], Decl(privateNameField.ts, 0, 9))
12+
>this.#name : Symbol(A.#name, Decl(privateNameField.ts, 0, 9))
1313
>this : Symbol(A, Decl(privateNameField.ts, 0, 0))
1414
>name : Symbol(name, Decl(privateNameField.ts, 2, 16))
1515
}

0 commit comments

Comments
 (0)