Windows及mac使用的 docker desktop 自带 docker-compose 工具。
只需要升级docker desktop 至最新版,就会安装 docker-compose v2
假设我们有一个接口结构,描述了响应的消息结构
tsinterface Res {
code: number;
status: string;
data: any;
}
大多数情况下code 与 status 实际值会来自于一组确定值的集合
比如:
0
/ 200
/ 10000
等‘success’
/ "failure"
等但是上面的类型标注太宽泛了,我们既不能在访问 code 时获得精确的提示,也失去了 TypeScript 类型即文档的功能。
这时就需要更精确的字面量类型、联合类型、枚举类型,提供精确地取值标注
例如,我们可以使用字面量类型、联合类型将上面的例子标注的更清楚
tsinterface Res {
code: 10000 | 10001 | 50000;
status: "success" | "failure";
data: any;
}
JavaScript的内置原始类型,在 TypeScript 中它们都有对应的类型注解
tsconst name: string = 'linbudu';
const age: number = 24;
const male: boolean = false;
const undef: undefined = undefined;
const nul: null = null;
const obj: object = { name, age, male };
const bigintVar1: bigint = 9007199254740991n;
const bigintVar2: bigint = BigInt(9007199254740991);
const symbolVar: symbol = Symbol('unique');
这一插件会收集你项目内所有的类型定义,在你敲出:时提供这些类型来进行补全。如果你选择了一个,它还会自动帮你把这个类型导入进来。