美文网首页
TypeScript 类型type的使用

TypeScript 类型type的使用

作者: chenjieyi | 来源:发表于2021-07-28 16:23 被阅读0次
  1. type 的基本使用
type Person = {
  isNormal: boolean;
  color: string;
};
  1. 多个type的使用
type Person = {
  isNormal: boolean;
  color: string;
};

type Car = {
  type: string;
  wheel: number;
};

type Drive = Person & Car;
  1. 使用type中的单个属性
type DriveTank = Person & { [K in 'wheel']: Car[K] };

相关文章

网友评论

      本文标题:TypeScript 类型type的使用

      本文链接:https://www.haomeiwen.com/subject/bsvzmltx.html