I know in TypeScript we can enforce specific strings like so:
const myStrings = ['foo', 'bar', 'baz'] as const;
type MyStringTypes = typeof myStrings[number];
However, what I would need is to enforce only the first characters of my final strings.
For instance, I would like to create a type (MyPrefixTypes) with something like 'prefix1', 'prefix2', ..., 'prefixN', followed by any other character.
Using this, I would be able to check if the string is correct or not.
Example:
const foo: MyPrefixTypes = 'prefix1blablabla'; // OK
const bar: MyPrefixTypes = 'incorrectprefixblablabla'; // NOT OK