You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to be able to create a function that dynamically types indexes, however currently I am unable to type terms:
When I hover over terms I get the following type constraint:
Type 'keyof T extends Data ? T : Data[]' is not assignable to type 'Join<NestedPaths<T extends Data ? T : Data>>[]'.
I noticed you are not exporting the Join / NestedPaths types. Is there a better way of achieving this? Am I missing something?
type NestedPaths<T> = T extends string | number | boolean ? [] : {
[K in Extract<keyof T, string>]: [K, ...NestedPaths<T[K]>];
}[Extract<keyof T, string>];
type Join<T> = T extends [] ? never : T extends [infer F] ? F : T extends [infer F, ...infer R] ? F extends string ? ${F}.${Join<Extract<R, string[]>>} : never : string;
The text was updated successfully, but these errors were encountered:
I want to be able to create a function that dynamically types indexes, however currently I am unable to type terms:
When I hover over terms I get the following type constraint:
Type 'keyof T extends Data ? T : Data[]' is not assignable to type 'Join<NestedPaths<T extends Data ? T : Data>>[]'.
I noticed you are not exporting the Join / NestedPaths types. Is there a better way of achieving this? Am I missing something?
type Join<T> = T extends [] ? never : T extends [infer F] ? F : T extends [infer F, ...infer R] ? F extends string ?
${F}.${Join<Extract<R, string[]>>}: never : string;
The text was updated successfully, but these errors were encountered: