const foo = <T>() => {};
const assign = <T, U>(a: T, b: U) => Object.assign(a, b);
const result: (() => void) & { foo: any } = assign(() => {}, { foo });
Argument of type '{ foo: <T>() => void; }' is not assignable to parameter of type '(() => void) & { foo: any; }'.
Type '{ foo: <T>() => void; }' is not assignable to type '() => void'.
Type '{ foo: <T>() => void; }' provides no match for the signature '(): void'.
TypeScript Version: 3.4.0-rc
Search Terms: Type parameters, generics, inference, regression
Code
Expected behavior:
No error
Actual behavior:
Playground Link:
https://www.typescriptlang.org/play/#src=const%20foo%20%3D%20%3CT%3E()%20%3D%3E%20%7B%7D%3B%0D%0Aconst%20assign%20%3D%20%3CT%2C%20U%3E(a%3A%20T%2C%20b%3A%20U)%20%3D%3E%20Object.assign(a%2C%20b)%3B%0D%0Aconst%20result%3A%20(()%20%3D%3E%20void)%20%26%20%7B%20foo%3A%20any%20%7D%20%3D%20assign(()%20%3D%3E%20%7B%7D%2C%20%7B%20foo%20%7D)%3B
Related Issues:
Removing
<T>fromfoomakes this code valid.