上一页 1 ··· 91 92 93 94 95 96 97 98 99 ··· 469 下一页
摘要: The definite assignment !: operator is used to suppress TypeScript’s objections about a class field being used, when it can’t be proven1 that it was i 阅读全文
posted @ 2022-08-03 20:11 Zhentiw 阅读(18) 评论(0) 推荐(0) 编辑
摘要: Requirements: function strBuilder(str) { return strBuilder; // TODO } var hello = strBuilder("Hello, "); var kyle = hello("Kyle"); var susan = hello(" 阅读全文
posted @ 2022-08-03 19:56 Zhentiw 阅读(22) 评论(0) 推荐(0) 编辑
摘要: value is Foo The first kind of user-defined type guard we will review is an is type guard. It is perfectly suited for our example above because it’s m 阅读全文
posted @ 2022-08-03 13:23 Zhentiw 阅读(46) 评论(0) 推荐(0) 编辑
摘要: class UnreachableError extends Error { constructor(_nvr: never, message: string) { super(message) } } class Car { drive() { console.log("vroom") } } c 阅读全文
posted @ 2022-08-03 01:59 Zhentiw 阅读(11) 评论(0) 推荐(0) 编辑
摘要: For the following class: class Car { make: string model: string year: number constructor(make: string, model: string, year: number) { this.make = make 阅读全文
posted @ 2022-08-01 17:17 Zhentiw 阅读(35) 评论(0) 推荐(0) 编辑
摘要: function f(...args) { return args; } function flip(fn) { return function flipped (arg1, arg2, ...args) { return fn(arg2, arg1, ...args) } } let z = fl 阅读全文
posted @ 2022-07-31 16:45 Zhentiw 阅读(19) 评论(0) 推荐(0) 编辑
摘要: Construct signatures are similar to call signatures, except they describe what should happen with the new keyword. interface DateConstructor { new (va 阅读全文
posted @ 2022-07-28 15:46 Zhentiw 阅读(82) 评论(0) 推荐(0) 编辑
摘要: Recursive types, are self-referential, and are often used to describe infinitely nestable types. For example, consider infinitely nestable arrays of n 阅读全文
posted @ 2022-07-27 19:15 Zhentiw 阅读(28) 评论(0) 推荐(0) 编辑
摘要: An interface is a way of defining an object type. An “object type” can be thought of as, “an instance of a class could conceivably look like this”. Fo 阅读全文
posted @ 2022-07-27 19:14 Zhentiw 阅读(26) 评论(0) 推荐(0) 编辑
摘要: function flipCoin(): "heads" | "tails" { if (Math.random() > 0.5) return "heads" return "tails" } function maybeGetUserInfo(): | ["error", Error] | [" 阅读全文
posted @ 2022-07-26 14:50 Zhentiw 阅读(37) 评论(0) 推荐(0) 编辑
上一页 1 ··· 91 92 93 94 95 96 97 98 99 ··· 469 下一页