kbrabrand / camelize-ts

A typescript typed camelCase function that recursively camel cases a snake cased object structure
25 stars 6 forks source link

Camelize doesn't work when used on Arrays #47

Closed LordZardeck closed 1 year ago

LordZardeck commented 1 year ago

If you try to run Camelize on an array, it returns an incorrect type. We've had to write a helper to get around this issue:

import type { Camelize as CamelizeObject } from ‘camelize-ts’

type Camelize<T> = T extends (infer U)[] ? CamelizeObject<U>[] : CamelizeObject<T>

It would be nice if the library just did this on the Camelize type in the first place

jonkoops commented 1 year ago

Hi @LordZardeck, if you think there is a solid solution feel free to open up a PR!