-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Better handlng of hyphenated properties #4032
Comments
That is a missing feature in the language service API. The assumption is that you will call getCompletions after a dot, something that is hyphenated is not valid after a dot; what we need to do is for get completions to return a substitution string, i.e. |
We would be open to take a PR for this if you are interested. |
I'm assuming that's in |
There's some amount of documentation in the wiki in the same section as this page: https://github.com/Microsoft/TypeScript/wiki/Architectural-Overview |
one thing to note here, is we need to do this in a way that is backward compatible, i.e. editor using the services today would not need ot make changes (or just minimum if at all). |
This issue is of particular interest to me as well. I wouldn't mind working on it over the weekend, but I have one question first, since my Google-fu failed, and I don't want to break my TSC setup just yet. ;) When I make my changes and I want to test them in Visual Studio, is it enough to overwrite the |
@bawr I would use Dev mode and have your language service file point to the one in your See https://github.com/Microsoft/TypeScript/wiki/Dev-Mode-in-Visual-Studio |
Sweet! I actually browsed through the wiki, but I neglected to look at the page listing after scrolling down, heh. |
Is this a duplicate of #606? |
it is related, #606 is mainly about specialized signatures. |
Okay, now that specialized signatures are just a weird special case of using string literal types, is this a duplicate of #606? |
it is related but not a duplicate. |
How are hyphenated properties handled now? Stuck on this today. Thanks! |
Seems this is fixed already |
Can you please provide an example of syntax or a link to such syntax? |
Works now, though note that this requires a compliant language service host that can handle non-insertive completions |
It is common in JavaScript to have hyphenated property names. For example:
The property "foo-bar" can be accessed like so:
From my use of TypeScript I've noticed that when using these in code or interfaces, TypeScript does not seem to reveal them as possible values. I'm talking about Intellisense, code completion, etc. I've noticed that when examining these types of properties in the Safari Web inspector, that it is aware these properties exist on the object. When you type
obj[
it will pop up all the possible object properties including the hypenated ones.I would hope it would be possible to reveal hyphenated object properties to the end user so that they can get completion for these types of hyphenated properties.
Here is an example of a recent ambient declaration I wrote:
When the user types:
Only the value
Accept
gets revealed, the other hyphenated values are ignored. Trying to use bracket notation does not work.The text was updated successfully, but these errors were encountered: