lesson 4 TS 2021-04-23

课程标题 路白-TS实战

知识点

基础知识

const a: number = 0;
a = 'a'; // 提示报错

emum Test {
     A,  // 默认是0, 如果赋值为数字,后面递增
     B,
     C
}
const type = Test.A;


type AjaxMethod = 'GET' | 'POST';

interface Test {
    name: string;
    height?:number;
}

const a: Test = {
    // 会提示包含的变量
}
  1. enum 枚举类型
  2. type interface
  3. 联合类型 |
  4. 交叉类型 &
  5. typeof: 用来获取一个变量声明或者对象的类型
  6. keyof: 可以用来获取一个对象中的所有key值
  7. in : 用来遍历枚举类型
  8. extends:

课后问题

你可能感兴趣的:(lesson 4 TS 2021-04-23)