4 ms·
The TypeScript compiler can enforce that, notice how the type annotation in the example is `'admin' | 'customer'`, not `string`. It's also possible to give thi
by incrudible 5y ago
The TypeScript compiler can enforce that, notice how the type annotation in the example is `'admin' | 'customer'`, not `string`.
It's also possible to give this type a name:
type UserCreationType = 'admin' | 'customer'
- PartiallyTyped 5y agoI see. Then I am joining the club where the first one was perfectly fine.
- beebeepka 5y agoYup, typescript is pretty good when it comes to this kind of stuff. This was one of the very few things I tried when I first started with TS.