interface 方式可以实现接口的 extends 和 implements , 而 type alias 则不行。
interface 可以实现接口的 merge ,但 type alias 则不行。
interface C { a: string; } interface C { b: number; } const obj:C = { a: '', }; // Error: Type '{ a: string; }' is not assignable to type 'C'. Property 'b' is missing in type '{ a: string; }'.
type C = { a: string; } // Error: Duplicate identifier 'C'. type C = { b: number; }
近期评论