上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 491 下一页
摘要: class ApplicationError extends Error { get name() { return this.constructor.name; } } class DatabaseError extends ApplicationError {} class UserFacing 阅读全文
posted @ 2024-08-11 22:06 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要: You can create a javascript file as a bash file: #!/usr/bin/env node console.log("Hello World!") Run the script: ./script.js 阅读全文
posted @ 2024-08-11 22:04 Zhentiw 阅读(13) 评论(0) 推荐(0)
摘要: class Product { name; price; constructor(name, price) { this.name = name; try { this.price = price * 1.30; } catch(e) { throw new Error("Product canno 阅读全文
posted @ 2024-08-11 22:03 Zhentiw 阅读(9) 评论(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 阅读(22) 评论(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 阅读(24) 评论(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 阅读(21) 评论(0) 推荐(0)
摘要: Docs: https://webkit.org/blog/6240/ecmascript-6-proper-tail-calls-in-webkit/ /* This is a recursive function without PTC */ function fatorial(n) { if 阅读全文
posted @ 2024-08-07 19:29 Zhentiw 阅读(11) 评论(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 阅读(12) 评论(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 阅读(14) 评论(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 阅读(11) 评论(0) 推荐(0)
上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 491 下一页