TSConfig

allowJs

Allow JavaScript files to be imported inside your project, instead of just .ts and .tsx files. For example, this JS file:

js
// @filename: card.js
export const defaultCardDeck = "Heart";
Try

When imported into a TypeScript file will raise an error:

ts
// @filename: index.ts
import { defaultCardDeck } from "./card";
 
console.log(defaultCardDeck);
Try

Imports fine with allowJs enabled:

ts
// @filename: index.ts
import { defaultCardDeck } from "./card";
 
console.log(defaultCardDeck);
Try

This flag can be used as a way to incrementally add TypeScript files into JS projects by allowing the .ts and .tsx files to live along-side existing JavaScript files.

It can also be used along-side declaration and emitDeclarationOnly to create declarations for JS files.