摘要:
Node.js 13.2.0 introduced support for native ES modules. This means you can natively run code containing thing like import { Foo } from 'bar', use top 阅读全文
摘要:
Let's say we need to use a library with commonJS code. class Melon { cutIntoSlices() { } } module.exports = Melon Then we want to import this inside o 阅读全文
摘要:
//////////////////////////////////////////////////////// // @filename: berries/raspberry.ts export class Raspberry { constructor(public color: 'red' | 阅读全文
摘要:
const NAME = "Matt"; TypeScript is telling us we can't redeclare the name variable because it has already been declared inside of lib.dom.d.ts. The in 阅读全文
摘要:
Example code: const routingConfig = { routes: [ { path: "home", component: "HomeComponent", }, { path: "about", component: 12, }, { path: "contact", c 阅读全文
摘要:
Creational patterns provide object creation mechanisms that increase flexibility and reuse of existing code. Factory method: Provides an interface for 阅读全文
摘要:
class Fish { swim(): void {} } class Bird { fly(): void {} } switch(true) { case val instanceof Bird: val.fly() break case val instanceof Fish: val.sw 阅读全文
摘要:
Normally you need to put require("dotenv").config() console.log(process.env.TEST) to access env vars WIth --node-fileflag you don't need to do that an 阅读全文
摘要:
const interValueFromColor = <N extends string, C extends string, T extends number>(colorTag: `${N}-${C}-${T}`) => { const [namespace, color, tone] = c 阅读全文
摘要:
// Before declare function createFSM<TState extends string>(config: { // Without NoInfer, TS doesn't know which // TState is the source of truth initi 阅读全文