doc: update typescript.md (#439)

修正类型技巧内Capitalize的推导结果
This commit is contained in:
2023-09-23 17:26:33 +08:00 committed by GitHub
parent ecb59d8980
commit 106d7aa602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1360,7 +1360,7 @@ const Row = (props: RowProps) => {
type Capitalize<T extends string> = T extends `${infer U}${infer V}` type Capitalize<T extends string> = T extends `${infer U}${infer V}`
? `${Uppercase<U>}${V}` ? `${Uppercase<U>}${V}`
: T : T
type capitalized = Capitalize<"hello world"> // Hello World type capitalized = Capitalize<"hello world"> // Hello world
``` ```
也可以在 infer 中使用条件约束(`extends` 也可以在 infer 中使用条件约束(`extends`