3 ms·
In some cases you can use it to define string arguments to an external library. Maybe table names to an ORM or a well-known file path. This helps because you ge
by brightstep 5y ago
In some cases you can use it to define string arguments to an external library. Maybe table names to an ORM or a well-known file path. This helps because you get autocomplete from typing `MyEnum.` and seeing options, even though the external function takes a plain string.
- afavour 5y agoAll of that is possible with a string literal union though, surely?
- brightstep 5y agoIt's not possible to get the autocomplete unless the function/method you're calling takes a union. Many libraries can't do that because they need to be flexible in what they receive. So yeah, you can define a union, but editors don't have the context to know your union applies to the call.