@@ -22,4 +22,6 @@ x = true;
export {}
// 解决重复变量定义
// 让ts作为独立的模块
-// 将编译后的js自动转成严格模式
+// 将编译后的js自动转成严格模式
+
+// Omit Pink区别
@@ -49,4 +49,35 @@ d = {
sex:Sex.man
}
console.log(d.sex == Sex.man ? '男' : '女')
+// 类型别名:通过type给类型起名字
+//格式: type 名字 = 类型
+// 1.联合类型
+type Sex1 = "man" | "woman";
+let e:Sex1;
+e = "man";
+// 2.字面量
+type status = 1|2|3;
+let f:status;
+f = 1;
+// 3.对象
+type info = {
+ name: string,
+ age: number,
+ address?:string
+}
+// let g:info = {
+// }
+// 交叉类型
+// 合并多个类型 变量必须同时满足所有类型的属性要求
+let h:{name:string} & {age:number};
+h = {
+ name:"图图",
+ age: 3