上一页 1 ··· 116 117 118 119 120 121 122 123 124 ··· 477 下一页
摘要: For example: const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const type result = TupleToObject<typeof tuple> // expected { tesla: 'tesla', 阅读全文
posted @ 2022-08-31 15:51 Zhentiw 阅读(60) 评论(0) 推荐(0)
摘要: For example: interface Todo { title: string description: string } const todo: MyReadonly<Todo> = { title: "Hey", description: "foobar" } todo.title = 阅读全文
posted @ 2022-08-31 15:26 Zhentiw 阅读(56) 评论(0) 推荐(0)
摘要: For example: interface Todo { title: string description: string completed: boolean } type TodoPreview = MyPick<Todo, 'title' | 'completed'> const todo 阅读全文
posted @ 2022-08-31 15:23 Zhentiw 阅读(64) 评论(0) 推荐(0)
摘要: Reuse existing instances when working with identical objects The flyweight pattern is useful when you're creating a huge number of objects, which coul 阅读全文
posted @ 2022-08-31 14:59 Zhentiw 阅读(37) 评论(0) 推荐(0)
摘要: You're given an array of integers and another array of three distinct integers. The first array is guaranteed to only contain integers that are in the 阅读全文
posted @ 2022-08-30 20:55 Zhentiw 阅读(52) 评论(0) 推荐(0)
摘要: Step 7: Tests for Types The assertion type code need to be tested just as the normal code. export function isITeam(arg: any): arg is ITeam { /** * { i 阅读全文
posted @ 2022-08-30 18:09 Zhentiw 阅读(75) 评论(0) 推荐(0)
摘要: Step1 & 2 for converting a js app to ts Step 3. Turn on "noImplicitAny" and even more strict mode Step 4. ESLint for Typescript Step5. Local types ove 阅读全文
posted @ 2022-08-30 18:09 Zhentiw 阅读(41) 评论(0) 推荐(0)
摘要: Step 5: Types at Runtime This problem often happens when APi return the data. let cachedAllTeamsList: Promise<ITeam[]>; export async function getAllTe 阅读全文
posted @ 2022-08-30 15:32 Zhentiw 阅读(52) 评论(0) 推荐(0)
摘要: Step5. Local types override You can find many @types package along with the library you use. But the problem is that those @types might contain bugs b 阅读全文
posted @ 2022-08-30 15:02 Zhentiw 阅读(41) 评论(0) 推荐(0)
摘要: Step 4: ESLint We need to install ESLint tools for Typescript. yarn add -D @typescript-eslint/eslint-plugin @typescript-eslint/parser .eslintrc file: 阅读全文
posted @ 2022-08-29 19:27 Zhentiw 阅读(418) 评论(0) 推荐(0)
上一页 1 ··· 116 117 118 119 120 121 122 123 124 ··· 477 下一页