interface Example {
a: string;
}
const notExample = { a: 5 }; // This object doesn't satisfy the interface Example
const errors: Example = Object.assign({}, notExample); // Type '{ a: number; }' is not assignable to type 'Example'.
const works: Example = Object.create(notExample); // Working correctly and it shouldn't
为什么Object.create
不为T
返回typeof Argument
,而是返回any
?
Object.assign
为传递的两个参数返回T & U
,正如一个人所期望的那样。