Open
Description
The following code is accepted by TypeScript tsc
5.8.3 but fails with tsgo
as of version 7.0.0-dev.20250603.1:
type IMapEntries<K, V> = [K, V][];
type IKeyValueMap<V> = {
[key: string]: V;
};
function testFunction<K, V>(initialValues?: IMapEntries<K, V> | IKeyValueMap<V>): void {}
const obj = {
key1: 'value1',
key2: 'value2',
key3: 'value3',
};
testFunction(Object.entries(obj).map(([key, value]) => [key, value]));
The error from tsgo
is:
test.ts(15,14): error TS2345: Argument of type 'string[][]' is not assignable to parameter of type 'IKeyValueMap<string> | IMapEntries<string, string> | undefined'.
Type 'string[][]' is not assignable to type 'IKeyValueMap<string> | IMapEntries<string, string>'.
Type 'string[][]' is not assignable to type 'IMapEntries<string, string>'.
Type 'string[]' is not assignable to type '[string, string]'.
Target requires 2 element(s) but source may have fewer.
Seemingly incidental changes such as inlining either of those type definitions into the function signature resolves the error.
This is a simplification of production code using the MobX observable.map
function.