Closed ghmendonca closed 1 year ago
Let's say that we have an object with this shape:
const object = { 'snake_field': 'snake', PascalField: 'pascal' }
Right now, this returns the type:
type Object = { snakeField: string, PascalField: string }
I believe the type should be:
type Object = { snakeField: string, pascalField: string }
This is very easy to do, all we need is to change CamelizeObject to:
CamelizeObject
type CamelizeObject<T, S = false> = { [K in keyof T as Uncapitalize<CamelCase<string & K>>]: T[K] extends Date ? T[K] : T[K] extends RegExp ? T[K] : T[K] extends Array<infer U> ? U extends {} | undefined ? Array<CamelizeObject<U>> : T[K] : T[K] extends {} | undefined ? S extends true ? T[K] : CamelizeObject<T[K]> : T[K]; };
The only thing that I changed, is that I added Uncapitalize before CamelCase. If this is fine, I can open a PR
Uncapitalize
CamelCase
That sounds sensible. A PR is welcome 👍
Yeah, this would definitely be an interesting contribution. Feel free to open up a PR!
Great! PR opened -> https://github.com/kbrabrand/camelize-ts/pull/50
Let's say that we have an object with this shape:
Right now, this returns the type:
I believe the type should be:
This is very easy to do, all we need is to change
CamelizeObject
to:The only thing that I changed, is that I added
Uncapitalize
beforeCamelCase
. If this is fine, I can open a PR