Closed as not planned
Closed as not planned
Description
π Search Terms
literals, union
β Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
β Suggestion
when we use union types, editor can't provide any suggestions.
type a = "a" | "b" | string
// typeof a:string
let v:a
v = "a" // β but without suggestion
v = "other" // β
If we remove string
from the union type, we wouldn't be able to set v
to any other value.
type a = "a" | "b"
// typeof a:"a"|"b"
let v:a
v = "a" // β with suggestion
v = "other" // β
I hope editor can give suggestion about "a"or"b"
π Motivating Example
we can give optional value suggestion to user, but user can use other type without error
π» Use Cases
- What do you want to use this for?
likedocument.body.style.borderWidth='inherit'
οΌeditor can give 'inherit'|'thin' and so on, but other string can be set. - What shortcomings exist with current approaches?
editor can't give more suggestions - What workarounds are you using in the meantime?
none
Metadata
Metadata
Assignees
Labels
No labels