allowJs lets JavaScript files into the program. tsc reads them, works out the types of what they export (from JSDoc where there is some, by inference elsewhere), and lets other files use those types. It does not report errors inside them: that is checkJs.
A file named jsconfig.json turns allowJs on by default, and in TypeScript 5.9 checkJs turns it on when you leave it out. In a JavaScript project you rarely write it; it matters in a tsconfig.json, and in projects that mix .ts and .js files.
At a glance
| Write | Nothing in a jsconfig.json, where it is already on. In a tsconfig.json, write "allowJs": true (or let "checkJs": true imply it) |
|---|---|
| On the command line | --allowJs |
| Type | boolean |
| Default in TypeScript 5.9 | false (on when checkJs is on and allowJs is left out) |
| Default in a jsconfig.json | true |
| TypeScript's description | Allow JavaScript files to be a part of your program. Use the 'checkJs' option to get errors from these files. |
The description is quoted from TypeScript's own option list (Apache-2.0); see the notices.
Examples
import { orderTotal } from "./legacy.js";
console.log(orderTotal([{ price: 400, qty: 2 }]));
console.log(orderTotal([{ price: "4.00", qty: 2 }]));error TS2322: Type 'string' is not assignable to type 'number'.jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": [
"*.js"
]
} In the program, but not checked
The example shows the difference in one project. legacy.js opts out of checking with // @ts-nocheck, so it is in the program the way allowJs alone puts a file there: its JSDoc still types orderTotal, and the call in checkout.js that passes a string price is an error. The misspelled toUppercase inside legacy.js is never reported, because nothing checks that file.
That is the whole job of allowJs: types flow out of JavaScript files. Turning on checkJs, or adding // @ts-check to one file, is what makes their own mistakes visible.
When you need to write it
Three cases, all outside a plain jsconfig.json:
- a config file named
tsconfig.jsonfor a JavaScript project: write"checkJs": true(which impliesallowJsin TypeScript 5.9) or both - a TypeScript project with some
.jsfiles left in it:"allowJs": truewithcheckJsoff lets.tsfiles import them, and// @ts-checkopts single files in as you convert them - a project that writes output from
.jsfiles (Babel-free downlevel builds, or.d.tsfiles for a package):allowJsis what lets those files be inputs
Gotchas
- With
allowJsand output turned on,tscwrites.jsfiles. WithoutoutDirornoEmit, it would write over your sources, so it stops with TS5055 instead. - JavaScript files inside
node_modulesare a separate setting:maxNodeModuleJsDepthdecides whether TypeScript reads them. - Setting
"allowJs": falsewhile"checkJs": trueis a config error in TypeScript 5.9 (TS5052): checking JavaScript needs JavaScript in the program.
Questions
Does allowJs check my JavaScript?
No. It makes .js files part of the program so their types are known. Errors inside them are reported only with checkJs on, or in a file that starts with // @ts-check.
Sources
- TSConfig Reference: allowJs · TypeScript
- TypeScript 1.8 release notes · TypeScript handbook
- Type Checking JavaScript Files · TypeScript handbook
Last reviewed 20 October 2026.