Skip to content

Camelizing nested properties with a null union breaks #51

Description

@LordZardeck

If you have a child prop that has a null union, Camelize stops trying to camelize that property. The following is a basic reproducable example:

import type { Camelize } from 'camelize-ts'
import camelize from 'camelize-ts'

type SnakeCasedChild = {
	foo_bar: string
}

type SnakeCasedParent = {
	child: SnakeCasedChild[] | null
}

type CamelCasedParent = Camelize<SnakeCasedParent>

const myObject: CamelCasedParent = camelize({
	child: [{ foo_bar: 'hello' }],
})

myObject.child?.map((child) => child.fooBar)

You'll notice that TypeScript complains that child.fooBar is not a valid property, but child.foo_bar is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions