There is a way to allow IntelliSense to work with union types like 'a' | 'b' | string
– writing it like 'a' | 'b' | string & {}
(or even using a helper type like type LiteralUnion<T extends U, U = string> = T | (U & {});
)
but is it possible for
type LiteralNumbersUnion = 10 | 20 | 30 | 40 | 50
type someProp = LiteralNumbersUnion | string
so that literal numbers would show up in Intellisense suggestions?
Here is an example of what I expect with literal string union and how it does not work with literal numbers union
Here’s a screenshot from TS Playground and another from VSCode, both with no autocomplete
LiteralNumbersUnion | string
disables intellisense, string & {}
clearly does not work because it solves a problem that does not exist (intersection between number and string types, at least as I understand it)
Actually, why don’t suggestions work here as is?
2