TypeScript Version: 2.7.0-dev.20180112
Code
interfaceIX{x: boolean;}functionfn<T>(obj: T,props: Partial<T>): (T&IX){constxobj=objasT&IX;xobj.x=true;for(constpinprops){// The following line causes a compilation error:// TS2322: Type 'Partial<T>[keyof T]' is not assignable to type '(T & IX)[keyof T]'.xobj[p]=props[p];}returnxobj;}Expected behavior:
This should compile since the members of Partial<T> is a subset of the members of (T & IX).
This does compile in 2.7.0-dev.20180108.
Actual behavior:
The following error is emitted when compiled:
index.ts(9,9): error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type '(T & IX)[keyof T]'.
Type 'T[keyof T]' is not assignable to type '(T & IX)[keyof T]'.
Type 'T' is not assignable to type 'T & IX'.
Type 'T' is not assignable to type 'IX'.
Related:
TypeScript Version: 2.7.0-dev.20180112
Code
Expected behavior:
This should compile since the members of
Partial<T>is a subset of the members of(T & IX).This does compile in 2.7.0-dev.20180108.
Actual behavior:
The following error is emitted when compiled:
Related: