Nullish coalescing operator but for conditional types #58629
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
π Search Terms
nullish coalescing operator
conditional types
β Viability Checklist
β Suggestion
Add syntactic sugar to allow this:
to be shorthand of:
π Motivating Example
When working with large complicated types, it is often that you need to check that a type extends another type before passing it as a type argument to another type.
For example, ensuring it is an array before passing it to something that requires it to be an array:
The more complex the type you need to check, the more you need to repeat yourself to pass the same type in again.
This proposal aims to address that.
π» Use Cases
Making my type code more readable and easier to maintain.
The need to repeat yourself. Updates to the type need to be make in two places.
The long-form syntax.
The text was updated successfully, but these errors were encountered: