typescript for toPairs doesn't match fromPairs
kerspoon opened this issue · 2 comments
I would expect that the typescript types for toPairs and FromPairs to match so that you can put them together
function identity(obj: MyObj): MyObj { const x = toPairs(obj); return fromPairs(x); }
currently they are:
export function fromPairs<V>(listOfPairs: readonly KeyValuePair<string, V>[]): { readonly [index: string]: V };
export function fromPairs<V>(listOfPairs: readonly KeyValuePair<number, V>[]): { readonly [index: number]: V };
export function toPairs<S>(obj: { readonly [k: string]: S } | { readonly [k: number]: S }): readonly (readonly [string, S])[];
and readonly KeyValuePair<string, V>[])
is not the same as readonly (readonly [string, S])[]
.
suggestion, add the following to typescript file:
export function fromPairs<V>(listOfPairs: readonly (readonly [number, V])[]): { readonly [index: number]: V };
export function fromPairs<V>(listOfPairs: readonly (readonly [string, V])[]): { readonly [index: string]: V };
I applied the change and it will go live with upcoming version 6.6.0
I will write again here when the release is made.
Closing this as 6.6.0
was released with this fix.