上一页 1 ··· 83 84 85 86 87 88 89 90 91 ··· 494 下一页
摘要: We have a type Route that is a discriminated union of the possible routes in the application. Each route has the properties search and route type Rout 阅读全文
posted @ 2022-12-13 15:26 Zhentiw 阅读(33) 评论(0) 推荐(0)
摘要: Let's say we have: type Fruit = "apple" | "banana" | "orange"; We only want AppleOrBanana If we do as such: type Fruit = "apple" | "banana" | "orange" 阅读全文
posted @ 2022-12-12 15:52 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要: Let's imagine you're building a type helper to extract out the value from several different 'parsers'. const parser1 = { parse: () => 1, }; const pars 阅读全文
posted @ 2022-12-12 15:40 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要: Example 1 import { S } from "ts-toolbelt"; import { Equal, Expect } from "../helpers/type-utils"; type Names = [ "Matt Pocock", "Jimi Hendrix", "Eric 阅读全文
posted @ 2022-12-12 15:20 Zhentiw 阅读(105) 评论(0) 推荐(0)
摘要: In this exercise we have an interface MyComplexInterface which is acting as a type helper. The interface takes arguments for Event, Context, Name, and 阅读全文
posted @ 2022-12-12 15:08 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要: import { Equal, Expect } from "../helpers/type-utils"; type GetPropValue< T extends Record<PropertyKey, any>, P extends keyof T = "data" > = T extends 阅读全文
posted @ 2022-12-11 22:33 Zhentiw 阅读(41) 评论(0) 推荐(0)
摘要: type NonEmptyArray<T> = [T, ...Array<T>]; export const makeEnum = (values: NonEmptyArray<string>) => {}; makeEnum(["a"]); makeEnum(["a", "b", "c"]); / 阅读全文
posted @ 2022-12-11 22:16 Zhentiw 阅读(16) 评论(0) 推荐(0)
摘要: export type Maybe<T extends {}> = T | null | undefined; type tests = [ // @ts-expect-error Maybe<null>, // @ts-expect-error Maybe<undefined>, Maybe<st 阅读全文
posted @ 2022-12-11 22:11 Zhentiw 阅读(23) 评论(0) 推荐(0)
摘要: import { Equal, Expect } from "../helpers/type-utils"; type Maybe<T> = T | null | undefined; type tests = [ Expect<Equal<Maybe<string>, string | null 阅读全文
posted @ 2022-12-11 22:03 Zhentiw 阅读(16) 评论(0) 推荐(0)
摘要: import { Equal, Expect } from "../helpers/type-utils"; type Identity<T> = T; type tests = [ Expect<Equal<Identity<1>, 1>>, Expect<Equal<Identity<"1">, 阅读全文
posted @ 2022-12-11 22:01 Zhentiw 阅读(33) 评论(0) 推荐(0)
上一页 1 ··· 83 84 85 86 87 88 89 90 91 ··· 494 下一页