随笔分类 -  TypeScript

上一页 1 2 3 4 5 6 ··· 30 下一页
摘要:To fix the CommonJS export issue, we need to make a change to our tsconfig.json file. Add the verbatimModuleSyntax setting and set it to true: { "comp 阅读全文
posted @ 2024-08-13 01:24 Zhentiw 阅读(69) 评论(0) 推荐(0) 编辑
摘要:The module and moduleResolution options in the tsconfig.json file can be confusing. Here we'll discuss the differences between the module and moduleRe 阅读全文
posted @ 2024-08-13 01:17 Zhentiw 阅读(26) 评论(0) 推荐(0) 编辑
摘要:Here we're attempting to import several PNG files into our TypeScript program: import pngUrl1 from "./example1.png"; // red squiggly line under "./exa 阅读全文
posted @ 2024-08-08 19:20 Zhentiw 阅读(7) 评论(0) 推荐(0) 编辑
摘要:Here we're importing a function myModuleFunc from my-module: import { myModuleFunc } from "my-module"; // red squiggly line under "my-module" Let's st 阅读全文
posted @ 2024-08-08 19:17 Zhentiw 阅读(14) 评论(0) 推荐(0) 编辑
摘要:In tsconfig file, you have targetand libsconfiguration. You always need to define a target, recommended as es2022 Specifying the lib option also lets 阅读全文
posted @ 2024-08-08 19:01 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:The declare keyword in TypeScript allows you to specify types for global variables. Whenever you use it, an ambient context is created, which means th 阅读全文
posted @ 2024-08-07 19:13 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:Typescript check a file whether it contains any export/import, if it is, then it's a module; if not then it's a script. What's the difference between  阅读全文
posted @ 2024-08-07 19:04 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:/** * How do we annotate the errors this function throws? */ type PossibleErrors = SyntaxError | DOMException; const getUserFromLocalStorage = (id: st 阅读全文
posted @ 2024-08-07 18:58 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:For the following code: const objOfFunctions = { string: (input: string) => input.toUpperCase(), number: (input: number) => input.toFixed(2), boolean: 阅读全文
posted @ 2024-08-07 17:53 Zhentiw 阅读(7) 评论(0) 推荐(0) 编辑
摘要:import { expect, it, vitest } from 'vitest'; const logId = (obj: { id: string }) => { console.log(obj.id); }; const logName = (obj: { name: string }) 阅读全文
posted @ 2024-08-06 19:56 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Make those pass: import { Equal, Expect } from "@total-typescript/helpers"; type Event = "click" | "hover" | "scroll"; type CallbackType = unknown; co 阅读全文
posted @ 2024-08-06 15:13 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要:function pipe<A, B>(fn: (a: A) => B) { function run(a: A) { return fn(a) } run.pipe = <C, >(fn2: (b: B) => C) => pipe((a: A) => fn2(fn(a))) return run 阅读全文
posted @ 2024-08-02 14:51 Zhentiw 阅读(9) 评论(0) 推荐(0) 编辑
摘要:type BaseTable = { [colName: string]: string | number | boolean; } type Columns<Tables extends { [tableName: string]: BaseTable }> = { [K in keyof Tab 阅读全文
posted @ 2024-08-02 14:50 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:class QueryBuilder { private fields: string[] = [] private wheres: Record<string, string> = {} private table: string = "" select(...columns: string[]) 阅读全文
posted @ 2024-08-02 14:19 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:import { expect, it, vitest } from 'vitest'; interface User { id: number; name: string; } function printUser(user: User) { Object.keys(user).forEach(( 阅读全文
posted @ 2024-08-01 15:12 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:interface User { id: number; name: string; } const users = [ { name: 'Waqas', }, { name: 'Zain', }, ]; const usersWithIds: User[] = users.map((user, i 阅读全文
posted @ 2024-08-01 14:46 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑
摘要:The error we encountered in this challenge was that the EventTarget | null type was incompatible with the required parameter of type HTMLFormElement. 阅读全文
posted @ 2024-07-29 20:27 Zhentiw 阅读(21) 评论(0) 推荐(0) 编辑
摘要:Value Objects are another pattern in Domain-driven Design that provide more structure around what you can and cannot do with a type. In TypeScript we 阅读全文
posted @ 2024-07-29 14:36 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:TypeScript will sometimes display the original Primitive Type rather than the Type Alias that you've set. By appending & {} to your Type Alias, you ca 阅读全文
posted @ 2024-07-25 22:26 Zhentiw 阅读(7) 评论(0) 推荐(0) 编辑
摘要:We start with three interface types: User, Organisation, and Product. These types share common properties: id, name, and imageId, but each also posses 阅读全文
posted @ 2024-07-11 14:50 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 30 下一页
点击右上角即可分享
微信分享提示