Guides
Guides to type-checked JavaScript
Guides are the longer reads: the ideas behind checking JavaScript with TypeScript, and the decisions a team makes when adopting it. Each one is dated, and its examples are checked like every other example on the site.
All guides, newest first
-
A JSDoc style guide for type-checked JavaScript
House rules for JSDoc that TypeScript checks: one comment style, where @typedefs live, naming, @import, @satisfies over casts, and Prettier settings.
-
Checking JavaScript in CI
Run tsc on every pull request: a GitHub Actions workflow, caching, monorepos, a pre-commit hook, and failing only on new errors with a baseline file.
-
Choosing a strictness level for checked JavaScript
Relaxed, recommended or strict: what each level of jsconfig.json strictness catches, what it costs in an existing codebase, and an order to turn options on.
-
How TypeScript reads a JavaScript file
How tsc reads a .js file: types from initializers, this and module.exports assignments, which JSDoc comments count, and what .js allows that .ts does not.
-
Migrating a JavaScript codebase to checked JavaScript, step by step
Move an existing JavaScript project to type-checked JavaScript one step at a time: per file, per folder, then noImplicitAny and strict, measuring as you go.
-
Reading a TypeScript error message
The parts of a tsc error: file, line and column, the TS code, message chains and related locations, and what --pretty and --explainFiles add.
-
Ship types from a JavaScript package
Publish a JavaScript package with types: write .d.ts files from JSDoc, point exports at them, check them as a consumer, and keep CommonJS users working.
-
The quirks of JSDoc in TypeScript
The surprises of type-checked JavaScript, each with an example checked by tsc: comments that attach to nothing, tags that do less than they say, loose types.
-
Who checks JavaScript with JSDoc instead of writing TypeScript
Svelte, SvelteKit, webpack, the unified collective, Lighthouse, Prettier and htmx check .js files with tsc: the evidence in each repository and their reasons.
-
Runtime type checks vs static type annotations in JavaScript
typeof and instanceof check values while code runs; TypeScript checks JSDoc-typed code before it runs. What each catches, and how they combine.