3 ms·
I don't quite get the point. If the function takes an argument of "hello", "world" or string, doesn't it still just take any string?
by schwartzworld 4y ago
I don't quite get the point. If the function takes an argument of "hello", "world" or string, doesn't it still just take any string?
- MrJohz 4y agoThe aim here is less about the types (like you say, any string will be valid) and more about autocomplete. When you start a string literal, you can technically type anything in there, but certain answers are more "correct" than others - i.e. these theme colour names. This technique allows you to tell Typescript-as-LSP which names it should suggest, while also letting Typescript-as-typechecker know that other options are also allowed.