I found a definition for a type level Split
function:
type Split<S extends string, D extends string> =
string extends S ? string[] :
S extends '' ? [] :
S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];
Is there also a way to create a type level Join<string[], string>
function, so I can use them for example for changing underscores to hyphens?
For example:
type ChangeHyphensToUnderscore<T> = { [P in keyof T & string as `${Join(Split<P, '-'>, '_')}`]: T[P] };