JSDoc · TypeScript · jsconfig.json
Type-checked JavaScript. No build step.
Write your types as JSDoc comments and let TypeScript's checker read them through one jsconfig.json file. Your .js files run exactly as written, and your editor and CI catch type errors before your users do.
Set up checking in three steps
TypeScript 5.9.3 · checked 21 October 2026-
Start a project
Terminalnpm init -y npm pkg set type=module npm install --save-dev typescript -
Create jsconfig.json
jsconfig.json{ "compilerOptions": { "checkJs": true, "noEmit": true, "strict": true, "module": "nodenext", "target": "es2022" } } -
Check your code
Terminalnpm pkg set scripts.lint="tsc -p jsconfig.json" npm run lintThis config checks
index.jsin the quick start on every build of this site.
- 0 build steps
- 1 config file
- 5 minutes
Why bother
What you get
The checking TypeScript users rely on, in the JavaScript you already write.
-
Editor hints
Completions, hovers and inline errors in every .js file, from comments you would write anyway.
-
Errors before runtime
Typos, wrong arguments and missing null checks fail in your editor and in CI, not in production.
-
Docs from the same comments
The JSDoc that types a function also documents it, for the checker, the editor and the next reader.
-
Publishable types
TypeScript can turn the same comments into .d.ts files, so people who install your package get types too.
The reference
Look it up
Tag and type pages pair the JSDoc with its TypeScript spelling, and every example in the reference passed (or failed exactly as shown) in tsc.
-
JSDoc tags
Every JSDoc tag as TypeScript reads it: syntax, support level, checked examples.
-
Type expressions
What goes inside the braces: unions, generics, object shapes, each next to its TypeScript spelling.
-
Config options
The jsconfig.json options that matter for JavaScript, and what each one changes.
-
Errors
The errors JavaScript projects meet first, what causes each one, and how to fix it.
-
Editors
Making your editor show the same errors as tsc, one editor at a time.
-
TypeScript releases
What each TypeScript release from 4.0 to 7.0 changed for JavaScript checked with JSDoc.
Recipes
How do I type this?
Answers to specific questions about real code, each one checked end to end. Six places to start, and 58 recipes in all.
-
- @param
- Optional parameters
- Default values
How do I mark a parameter as optional in JSDoc?
Some of my function's parameters can be left out, and some have default values. How do I write that in JSDoc so callers may skip them and tsc still checks what they pass?
-
- @template
- Generics
- keyof
How do I write a generic function in JavaScript with @template?
I have small helpers like last(), indexById() and pluck() that work on any array. With @param {any[]} they lose the element type. How do I make them generic in JSDoc?
-
- Enums
- @typedef
- Object.freeze
How do I write an enum in JavaScript with JSDoc?
In TypeScript I would write enum OrderStatus. My code is plain JavaScript. How do I get a fixed set of named values that tsc checks, and what is wrong with the @enum tag?
-
- @import
- @typedef
- import() types
How do I import and re-export types between JavaScript files?
I define Order and LineItem with @typedef in one file. How do I use them in other files, and how do I collect the types of several modules in one place for the rest of the app to import?
-
- DOM
- querySelector
- instanceof
How do I type document.querySelector results in JavaScript?
document.querySelector('#email').value fails with 'possibly null' and 'Property value does not exist on type Element'. The element is always on the page. What is the right way to get an input element in JSDoc-checked code?
-
- React
- JSX
- @typedef
How do I type React component props in a .jsx file?
My React app is written in .jsx files. How do I declare a component's props in JSDoc so a missing or wrong prop is caught where the component is used, without switching to .tsx?
Guides
Read further
The longer reads: migrating a codebase, the quirks of JSDoc, shipping types, CI. Dated, so you know how current they are.
-
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.
Compare
Weigh it up
Checked JavaScript next to the alternatives: TypeScript files, Node's type stripping, Flow, other runtimes and TypeScript's own versions.
-
JSDoc-typed JavaScript vs TypeScript files
The same checker reads both. What differs is syntax, the build step, and what each can express: a dated comparison with examples checked by tsc.
-
JSDoc-typed JavaScript vs Node's type stripping
Node.js now runs .ts files by erasing their types. What that changes about the no-build-step argument, what it does not do, and which Node.js versions do it.
-
jsconfig.json vs tsconfig.json
The same file format with different defaults: what a jsconfig.json turns on by itself, how tsc and editors find each file, and when to use which.
-
TypeScript 5.9 vs 6.0 vs 7.0 for JavaScript projects
What changes for checked JavaScript across TypeScript 5.9, 6.0 and the 7.0 native port: defaults, removed options, JSDoc 7.0 drops, speed, and an upgrade path.
-
JSDoc with TypeScript vs Flow
Two ways to type JavaScript in comments: TypeScript's checker reading JSDoc, and Flow's comment types. Where each stands today, and how to move from Flow.
-
Checking JavaScript in Node.js, Deno and Bun
What each runtime checks before and while it runs your JavaScript, which config each reads, and the commands, with one sample file checked by tsc.
Where the name comes from
A talk, a tool, and now a reference
The name comes from a 2022 conference talk by AJ ONeal that made the case for typed JavaScript without transpiling, and from the setup tool he published with it. This site is an independent reference for the same idea.
The historyCheck your first file today
One config file and one npm script. Your code runs exactly as it does now; it just gets checked first.
Start in 5 minutesType-checked JavaScript. No build step.