diff --git a/docs/typescript.html b/docs/typescript.html index b0c18234..92de7cca 100644 --- a/docs/typescript.html +++ b/docs/typescript.html @@ -42,7 +42,7 @@
包含最重要基础、泛型、方法、class 等 TypeScript 强类型编程语言语法的快速参考备忘单。初学者的完整快速参考。
TypeScript 是具有类型语法的 JavaScript。Interface 是为了匹配它们的运行时行为而构建的。
interface Point {
+ x: number;
+ y: number;
+}
+
+// type keys = "x" | "y"
+type keys = keyof Point;
+
+interface NumberOrString {
+ [index: string]: string | number;
+ length: number;
+ name: string;
+}
+
+type Point = { x: number; y: number; }
+type Data = Point[];
+// Data 是个数组,提取里面的元素类型
+type PointDetail = Data[number];
+// type PointDetail = { x: number; y: number; }
+
+const point = [3, 4] as const
+// type 'readonly [3, 4]'
+