@@mrlectus so what is the point then? I understand it's demonstrating some power, but it needs a concrete application. I was actually trying to define a type where you could pass snake case to a function and not other cased strings. It is hard to do. This seems like maybe it's heading in that direction, but then it only appears to work by creating too specific of types. Help.
great video!
I'm not understanding how you can actually use this type in the real world. What can you do with this CamelCase type in a real application?
That's not the point
@@mrlectus so what is the point then? I understand it's demonstrating some power, but it needs a concrete application.
I was actually trying to define a type where you could pass snake case to a function and not other cased strings. It is hard to do.
This seems like maybe it's heading in that direction, but then it only appears to work by creating too specific of types.
Help.
@@batsshadow consider using the `never` type? i think you could say something like
type SnakeOnly = T extends SnakeCase? T : never
type snakeCase<
T extends string,
Acumulator extends string = ""
> = T extends `${infer First}${infer Rest}`
? First extends Capitalize
? snakeCase
: snakeCase
: Acumulator;
type camelCase = T extends `${infer Before}_${infer After}`
? camelCase
: T;