TypeScript Compiler Options
customConditions — TypeScript compiler option
Adds condition names in Node16, NodeNext or Bundler resolution. Package object key order governs the first matching branch, not the order of the custom condition array. Configure runtime conditions separately. Default (5.8.3): no additional conditions. 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": { "customConditions": [ "development" ] }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| customConditions | string array | Set in compilerOptions; default: no additional conditions. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "ESNext", "strict": true, "types": [], "noEmitOnError": true, "noEmit": true, "moduleResolution": "Bundler", "customConditions": [ "development" ] }, "files": [ "main.ts" ]}// File: main.tsimport { mode } from "demo"; const checked: "dev" = mode;// File: node_modules/demo/package.json{ "name": "demo", "exports": { ".": { "development": "./dev.d.ts", "default": "./prod.d.ts" } }}// File: node_modules/demo/dev.d.tsexport declare const mode: "dev";// File: node_modules/demo/prod.d.tsexport declare const mode: "prod";