I am trying to workaround a deficiency in yargs library where types for configuration are produced both as kamelCase and kebab-case, e.g.
const argv = yargs
.env('CAS')
.help()
.options({
'app-path': {
demand: true,
type: 'string',
},
})
.parseSync();
export type Configuration = typeof argv;
Now Configuration is {'app-path': string, appPath: string}.
I want to Omit dash-containing keys. However, how do I Pick all keys that contain a dash in the first place?
>Solution :
Template literal types to the rescue:
type A = { 'app-path': string, appPath: string }
type B = Omit<A, `${string}-${string}`>;