TypeScript Compiler Options

resolvePackageJsonExports — TypeScript compiler option

Controls whether supported resolvers consult package exports. Export maps may hide existing files. Disabling TypeScript lookup restrictions does not disable runtime package encapsulation. Default (5.8.3): true for Node16, NodeNext and Bundler; otherwise false. Create the labeled files in an isolated local project and run tsc -p tsconfig.json. Expected: no diagnostics; emitted files: none. Local multi-file fixture, not a single-file editor.

Formal Syntax & Structure

typescript syntaxtypescript
{  "compilerOptions": {    "resolvePackageJsonExports": false  }}

Parameters & Attributes

NameTypeDescription
resolvePackageJsonExportsbooleanSet in compilerOptions; default: true for Node16, NodeNext and Bundler; otherwise false.

Working Example

Example Snippettypescript
// File: tsconfig.json (omit this label){  "compilerOptions": {    "target": "ES2022",    "module": "ESNext",    "strict": true,    "types": [],    "noEmitOnError": true,    "noEmit": true,    "moduleResolution": "Bundler",    "resolvePackageJsonExports": false  },  "files": [    "main.ts"  ]}// File: main.tsimport { value } from "demo/hidden"; const checked: number = value;// File: node_modules/demo/package.json{  "name": "demo",  "exports": {    ".": "./index.js"  }}// File: node_modules/demo/index.d.tsexport declare const value: number;// File: node_modules/demo/hidden.d.tsexport declare const value: number;
TypeScript Reference