3 ms·
I do a lot of TypeScript these days. It's possible to define a type which equates to one or more literal string values. The TypeScript compiler will complain if
by JMTQp8lwXL 7y ago
I do a lot of TypeScript these days. It's possible to define a type which equates to one or more literal string values. The TypeScript compiler will complain if you try and supply an invalid string parameter. So --at least for TypeScript-- I think this is less of a concern than in the past (and TypeScript is growing in popularity within the JS community). In a more general sense, I agree with the author that the 2nd code sample offers additional clarity.
- nemetroid 7y agoThat sounds like a type that holds a string, which is just what the article suggested to use.
- JMTQp8lwXL 7y agoWhich, prior to TypeScript, wouldn't have been an option. The ever-evolving front end ecosystem!