Convert a string literal to camel-case.
This can be useful when, for example, converting some kebab-cased command-line flags or a snake-cased database result.
Signature:
export declare type CamelCase<K> = K extends string ? CamelCaseStringArray<Split<K, WordSeparators>> : K;
import {CamelCase} from 'type-fest';
// Simple
const someVariable: CamelCase<'foo-bar'> = 'fooBar';
// Advanced
type CamelCasedProps<T> = {
[K in keyof T as CamelCase<K>]: T[K]
};
interface RawOptions {
'dry-run': boolean;
'full_family_name': string;
foo: number;
}
const dbResult: CamelCasedProps<ModelProps> = {
dryRun: true,
fullFamilyName: 'bar.js',
foo: 123
};