Skip to content

Fix display of private names in the TS Language Server #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

joeywatts
Copy link

The language server was displaying private names in the form of A[#privateName] instead of A.#privateName. (One place where this is visible is when you hover over a private name in VSCode.) This change to the checker will use the property access with private names instead of element access.

@@ -4048,7 +4048,10 @@ namespace ts {
context.flags ^= NodeBuilderFlags.InInitialEntityName;
}
let firstChar = symbolName.charCodeAt(0);
const canUsePropertyAccess = isIdentifierStart(firstChar, languageVersion);
const canUsePropertyAccess = firstChar === CharacterCodes.hash ?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to check the name node itself rather than rely on checking for #. Something like:
isNamedDeclaration(symbol.valueDeclaration) ? isPrivateName(symbol.valueDeclaration.name)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have to use the symbol name because apparently valueDeclaration can be undefined. Making the change to check isNamedDeclaration(valueDeclaration) crashes tons of tests because it's undefined.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{vw}

Joseph Watts added 2 commits December 10, 2018 11:05
Signed-off-by: Joseph Watts <jwatts43@bloomberg.net>
Signed-off-by: Joseph Watts <jwatts43@bloomberg.net>
@joeywatts joeywatts force-pushed the private-name-server-display branch from 72285d1 to 3fc3756 Compare December 10, 2018 16:20
@Neuroboy23 Neuroboy23 merged commit 979155c into bloomberg:es-private-fields Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants