-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Completion should prefer literal types in union types #13614
Comments
Duplicate of #12687. |
@andy-ms, from your comment in the other thread, it sounds like someone chose to make a regression in tooling in exchange for a compiler optimization. For a language like TypeScript where one of its largest features is good tooling, I think this is a mistake. The TypeStyle project leverages literal types to provide good auto-completion for css property values. A lot of properties have exact keywords for which type ahead support is great. However, a lot of these can also take units like 3px which can't be described to the type system, so we have to fallback to a string. Here is an issue recently brought by a developer using TypeStyle: typestyle/typestyle#104 What would it take to restore this behavior? |
I agree with @notoriousb1t . This is a feature I really want; there's tons of instances where it can make writing quality code quicker—one of the things about TypeScript that makes the DX so great. Granted, the spec does denote that in such cases the union would get widened to
That's such a cop-out man. I'm not familiar with the internals of the type checker, but surely some metadata could be supplied to the completion provider alongside the results from the type checker. |
TypeScript Version: 2.2.0-dev.20170120
Code
Expected behavior:
The auto completion list shows 'inline-block' followed by general string suggestions
Actual behavior:
The auto completion list shows general string suggestions none of which are 'inline-block;
The text was updated successfully, but these errors were encountered: