TypeScript Compiler Options

maxNodeModuleJsDepth — TypeScript compiler option

Controls how deeply JavaScript under node_modules is included for inference when allowJs is enabled. Increasing depth may improve inferred dependency types but add cost; prefer accurate declarations when available. Not a runtime dependency loader. Default (5.8.3): 0. Create the labeled files in an isolated project and run tsc -p tsconfig.json. No diagnostics; output: none. Local project fixture, not a single-file editor.

Formal Syntax & Structure

typescript syntaxtypescript
{  "compilerOptions": {    "maxNodeModuleJsDepth": 1  }}

Parameters & Attributes

NameTypeDescription
maxNodeModuleJsDepthnon-negative integerSet in compilerOptions; default: 0.

Working Example

Example Snippettypescript
// File: tsconfig.json (omit this label){  "compilerOptions": {    "target": "ES2022",    "module": "CommonJS",    "strict": true,    "types": [],    "noEmitOnError": true,    "noEmit": true,    "allowJs": true,    "noImplicitAny": false,    "maxNodeModuleJsDepth": 1  },  "files": [    "main.ts"  ]}// File: main.tsimport { count } from "demo";const value: string = count;// File: node_modules/demo/package.json{"name":"demo","main":"index.js"}// File: node_modules/demo/index.jsexports.count = "text";
TypeScript Reference