shaKY-iota / type-challenges

Collection of TypeScript type challenges with online judge
https://tsch.js.org/
MIT License
0 stars 0 forks source link

610 - CamelCase #27

Open shaKY-iota opened 2 years ago

shaKY-iota commented 2 years ago
// your answers
type CamelCase<S extends string> =
  S extends `${infer T}-${infer U}`? U extends Capitalize<U> ? `${T}-${CamelCase<U>}` : `${T}${CamelCase<Capitalize<U>>}` : S;
shaKY-iota commented 2 years ago
type CamelCase<S extends string> =
  S extends `${infer T}-${infer U}` ? `${T}${U extends Capitalize<U> ? `-${CamelCase<U>}` : `${CamelCase<Capitalize<U>>}`}` : S;