// Works fine in 4.3.5, not in 4.4.2
type ArgsTupleUnion<T> =
| [obj: T, x: (arg: T) => void]
| [y: (arg: number) => void];
function f<T>(...args: ArgsTupleUnion<T>) {}
f({ k: 15 }, (arg) => { // 4.3.5: arg is {k: number}, 4.4.2: arg is 'any'
console.log(arg.k);
});
f((a: number) => {});
type ArgsTuple<T> =
| [obj: T, x: (arg: T) => void]
// | [y: (arg: number) => void];
function f2<T>(...args: ArgsTuple<T>) {}
f2({ k: 15 }, (arg) => { // Both 4.3.5 and 4.4.2: arg is {k: number}
console.log(arg.k);
});
Here's the code on TS Playground. I'm not sure which change has made this stop working but it's preventing me from upgrading to 4.4. Anyone else who has run into this or has an idea for a workaround?
[y: (arg: T) => void]