Non strict string literal types
Hey everyone. I want to keep intellisense suggestions when defining something like this:
I want to be able to accept any other string but have suggestions when defining a variable.
I am not sure what would be the right keyword to search for in this situation.
7 Replies
Using uppercase
String
seems to be working, though I am not sure if it is completely safe to do so in my situation with React stuff. It is only defined as a type, so I am assuming it wouldn't do some coersion in the background
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
the utility type is a cool idea, thanks!
GitHub
Literal String Union Autocomplete · Issue #29729 · microsoft/TypeSc...
Autocomplete works for literal string unions, but adding a union of string negates autocomplete entirely. This has been brought up before but I believe there is enough value in this feature to be r...
It's your lucky day, THE typescript wizard has a video explaining how to do it and why it works this way
Matt Pocock
YouTube
Building LOOSE AUTOCOMPLETE with TypeScript - Advanced TypeScript
Become a TypeScript Wizard with Matt's upcoming TypeScript Course:
https://www.mattpocock.com/
Follow Matt on Twitter
https://twitter.com/mattpocockuk
all hail the wizard 🧙♂️