交叉类型

Tutorial: TS初级一 Category: TS Published: 2026-04-07 13:58:26 Views: 20 Likes: 0 Comments: 0
  1. 交叉类型演示
interface Person {
  name: string;
  say(): number;
}

interface Contact {
  phone: string;
}

type PersonDetail = Person & Contact;

let obj: PersonDetail = {
  name: "jack",
  phone: "133....",
  say() {
    return 1;
  },
};
Prev: Next: 泛型