function test<T extends {accepted: boolean}>(cb: (value: T) => void) {
return (data: Omit<T, 'accepted'>) => cb({...data, accepted: true});
}
Argument of type 'Pick<T, Exclude<keyof T, "accepted">> & { accepted: true; }' is not assignable to parameter of type 'T'.
'Pick<T, Exclude<keyof T, "accepted">> & { accepted: true; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ accepted: boolean; }'.
TypeScript Version: 3.7.2, also tested in nightly (3.8.0-dev.20191224)
Search Terms:
"is assignable to the constraint of type", "could be instantiated with a different subtype of constraint"
Code
Expected behavior:
No error
Actual behavior:
Playground Link: http://www.typescriptlang.org/play/?ts=3.8.0-dev.20191224&ssl=1&ssc=1&pln=4&pc=1#code/GYVwdgxgLglg9mABFApgZygHgCqJQD1TABM1EBvAQwghQAdViAuRAIzjgBsVKwBfAHwAKCKxZCAbpU4gULbAEpEAXgGIJcGMSXkAUIkQAnFFBCGkQ4pSiUWAeQC2MLNgA0iAOTVaDFMQ8CSqqIokLkAHSRVjbu3vSMLFCGsnwKANy6fLpAA
Related Issues: