Skip to content

Commit

Permalink
Merge pull request #11 from joeywatts/private-name-server-display
Browse files Browse the repository at this point in the history
Fix display of private names in the TS Language Server
  • Loading branch information
Neuroboy23 authored Dec 10, 2018
2 parents b29c9cf + 3fc3756 commit 979155c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4171,7 +4171,10 @@ namespace ts {
context.flags ^= NodeBuilderFlags.InInitialEntityName;
}
let firstChar = symbolName.charCodeAt(0);
const canUsePropertyAccess = isIdentifierStart(firstChar, languageVersion);
const canUsePropertyAccess = firstChar === CharacterCodes.hash ?
symbolName.length > 1 && isIdentifierStart(symbolName.charCodeAt(1), languageVersion) :
isIdentifierStart(firstChar, languageVersion);

if (index === 0 || canUsePropertyAccess) {
const identifier = setEmitFlags(createIdentifier(symbolName, typeParameterNodes), EmitFlags.NoAsciiEscaping);
identifier.symbol = symbol;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/privateNameField.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ class A {
>A : Symbol(A, Decl(privateNameField.ts, 0, 0))

#name: string;
>#name : Symbol(A[#name], Decl(privateNameField.ts, 0, 9))
>#name : Symbol(A.#name, Decl(privateNameField.ts, 0, 9))

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

this.#name = name;
>this.#name : Symbol(A[#name], Decl(privateNameField.ts, 0, 9))
>this.#name : Symbol(A.#name, Decl(privateNameField.ts, 0, 9))
>this : Symbol(A, Decl(privateNameField.ts, 0, 0))
>name : Symbol(name, Decl(privateNameField.ts, 2, 16))
}
Expand Down

0 comments on commit 979155c

Please sign in to comment.