hughsk / flat

:steam_locomotive: Flatten/unflatten nested Javascript objects
BSD 3-Clause "New" or "Revised" License
1.78k stars 196 forks source link

Return type of flatten/unflatten #179

Open stychu opened 1 month ago

stychu commented 1 month ago

How Do i get the result type being properly typed?? Instead I get unknown as a result of flatter/unflatten

unflatten(values);

function unflatten<{
    "locationDetails. id": string;
    "locationDetails. name": string;
    "locationDetails. storeFormat": {
        label: string;
        value: string;
    } | null;
    ... 40 more ...;
}, unknown>(     target: {},     options?: UnflattenOptions): unknown
jonkoops commented 1 month ago

Can you provide a minimal and reproducible example of your issue?

stychu commented 1 month ago

Repro

stychu commented 1 month ago

This seem to work as I would expect the unflatten to work but do I need type casting for this library to work like this ?

UnFlatten type

jonkoops commented 1 month ago

This seem to work as I would expect the unflatten to work but do I need type casting for this library to work like this ?

No you should not need to, this is certainly a bug of some sort.