Async & modules
8 steps in 4 sets of TypeScript.
Eight steps on the boundary. Typing promises and async functions, typed event emitters, then modules and declaration files.
Short and pointed. The declaration files set is the one to pay attention to, because it is how you type a dependency that shipped without types.
Async types
- Typed async codePromise return types and asserting fetched shapes.
- Typing async codePromise types, awaited results, and typing a fetch wrapper.
Typed events
- A typed event emitterA map of event names to payloads makes on and emit type-safe.
- Tiny event emitterAn event emitter where the event name determines the payload type.
Modules & declarations
- Type-only importsImporting a type without importing a value, so the import can vanish.
- Declaration filesA .d.ts describes shapes with no implementation.
- Module augmentationAdding to another module's types from your own code.
Encore
- task-queue.tsA typed task queue running jobs with bounded concurrency.