A package's exports map can point to different files under different conditions: import, require, node, and any names the package invents, such as development. Node.js uses the extra ones only when you run it with --conditions (-C); bundlers have a setting for them. customConditions tells the checker to use the same ones, so it reads the files your code will actually load.
It works with moduleResolution set to node16, nodenext or bundler, and arrived with TypeScript 5.0.
At a glance
| Write | Only when your runtime or bundler resolves packages with extra conditions: list the same ones, for example ["development"] |
|---|---|
| On the command line | --customConditions |
| Type | string[] |
| Default in TypeScript 5.9 | not set |
| TypeScript's description | Conditions to set in addition to the resolver-specific defaults when resolving imports. |
The description is quoted from TypeScript's own option list (Apache-2.0); see the notices.
Examples
import { log, trace } from "tiny-log";error TS2305: Module '"tiny-log"' has no exported member 'trace'.
log("start");
trace("here");jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": [
"*.js"
]
} import { log, trace } from "tiny-log";
log("start");
trace("here");jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": [],
"customConditions": [
"development"
]
},
"include": [
"*.js"
]
} Keep it in step with the runtime
The examples use a package whose development entry exports an extra trace function. Checked with the default conditions, trace does not exist (TS2305); with customConditions: ["development"] it does. If you run node -C development main.js, the second config describes your program; if you run plain node main.js, the first one does, and trace really would be missing.
Gotchas
- Conditions are read in the package's order, not yours: the first matching key in the
exportsmap wins.
Sources
- TSConfig Reference: customConditions · TypeScript
- TypeScript 5.0 release notes · TypeScript handbook
- Modules: Packages, conditional exports · Node.js docs
Last reviewed 20 October 2026.