Description:
Optional nested arrays are not callable after being assigned Camelize type with appropriate generic.
Steps to Reproduce:
- Import the
Camelize type from 'camelize-ts'.
- Declare a variable
bar of type Camelize<{ foo?: string[] }[]> and initialize it with an array containing an object with an optional foo property.
- Attempt to use the
map method on baz (the nested array items).
import { Camelize } from 'camelize-ts'
const bar: Camelize<{ foo?: string[] }[]> = [
{
foo: ['abc'],
},
]
bar.map((baz) => baz.foo?.map((x) => x))
// 1. This expression is not callable. (<- it's referring to baz.foo.map not the bar.map call.)
// Type 'CamelizeObject<(<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]), false>' has no call signatures. [2349]
Expected Behavior:
The map method should work as expected, allowing access to the foo property and its elements (if I remove the optional marker in the generic then things do work as expected i.e. Camelize<{ foo:string[] }[]>)
Actual Behavior:
The TypeScript compiler raises an error, stating: "This expression is not callable. Type 'CamelizeObject<((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]), false>' has no call signatures."
Additional Information:
- Library Version: 3.0.0
- TypeScript Version: 5.2.2
Note:
This issue affects the usability of the library when working with optional nested arrays, and a solution or workaround would be greatly appreciated.
Description:
Optional nested arrays are not callable after being assigned
Camelizetype with appropriate generic.Steps to Reproduce:
Camelizetype from 'camelize-ts'.barof typeCamelize<{ foo?: string[] }[]>and initialize it with an array containing an object with an optionalfooproperty.mapmethod onbaz(the nested array items).Expected Behavior:
The
mapmethod should work as expected, allowing access to thefooproperty and its elements (if I remove the optional marker in the generic then things do work as expected i.e.Camelize<{ foo:string[] }[]>)Actual Behavior:
The TypeScript compiler raises an error, stating: "This expression is not callable. Type 'CamelizeObject<((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]), false>' has no call signatures."
Additional Information:
Note:
This issue affects the usability of the library when working with optional nested arrays, and a solution or workaround would be greatly appreciated.