TypeScript Version: 2.3.4
Code
functionshallowCopy<T,UextendsT>(s: T,d: U){Object.keys(s).forEach((k: keyofT)=>d[k]=s[k]);}Expected behavior:
I would expect this function to compile, since U is a sub class of T and U's keys are presumably treated as superset of T's keys. Each key of T should be a key of U as well.
Actual behavior:
TypeScript reports the following error: "Type 'T[keyof T]' is not assignable to type 'U[keyof T]'."
TypeScript Version: 2.3.4
Code
Expected behavior:
I would expect this function to compile, since U is a sub class of T and U's keys are presumably treated as superset of T's keys. Each key of T should be a key of U as well.
Actual behavior:
TypeScript reports the following error: "Type 'T[keyof T]' is not assignable to type 'U[keyof T]'."