TypeScript Problem: I want a string literal union type, but I also want to...
TypeScript Problem: I want a string literal union type, but I also want to call a function that accepts a string in a type-safe manner. (Assume I can’t change the types on the function’s signature because it’s owned by a third party).
Solution:
1. Create a map const
2. Derive the string literal union from the map const.
No enum required. (I avoid enums).
Now I can use both types, and they’re guaranteed to stay in sync.

Many people suggest wrapping the third party function to narrow the type.
That also works.
But if you do, it’s important to configure a linter to enforce only calling the wrapped function.
ESLint no-restricted-imports helps here.
https://eslint.org/docs/latest/rules/no-restricted-imports