diff --git a/CONTRIBUTORS.svg b/CONTRIBUTORS.svg index 94128974..f7345966 100644 --- a/CONTRIBUTORS.svg +++ b/CONTRIBUTORS.svg @@ -14,23 +14,21 @@ - - - + - + - + - + - + - + - + - + \ No newline at end of file diff --git a/docs/typescript.html b/docs/typescript.html index 43b8b9fd..cb85d3a2 100644 --- a/docs/typescript.html +++ b/docs/typescript.html @@ -42,7 +42,7 @@

包含最重要基础、泛型、方法、class 等 TypeScript 强类型编程语言语法的快速参考备忘单。初学者的完整快速参考。

入门 Interface

+

入门 Interface

介绍

TypeScript 是具有类型语法的 JavaScript。Interface 是为了匹配它们的运行时行为而构建的。

    @@ -974,8 +974,20 @@ const Form = () => <Select<string> items={['a', 'b']} />;

各种各样的技巧

-

keyof 取 interface 的键

- +

类型推导(infer)

+ +
type Capitalize<T extends string> = T extends `${infer U}${infer V}`
+  ? `${Uppercase<U>}${V}`
+  : T
+type capitalized = Capitalize<"hello world"> // Hello World
+
+
    +
  • 也可以在 infer 中使用条件约束(extends
  • +
+
type SomeBigInt = "100" extends `${infer U extends bigint}` ? U : never;
+// 100n
+
+

keyof 取 interface 的键

interface Point {
     x: number;
     y: number;