Framework - Express.js
Configure TypeScript for an Express.js server so module resolution matches how Node.js loads your code.
Why Use This Preset?
- Sets
NodeNextmodule and resolution so imports follow Node.js ECMAScript module rules. - Targets the latest ECMAScript library so server code can use current language APIs.
- Keeps the configuration server-focused without pulling in DOM types you do not need.
- Layers cleanly after
dx-essentialsanddx-strictso framework settings stay in their own reviewable layer.
Usage
Add the preset to the extends array of your tsconfig.json, after the essentials and strict layers.
tsconfig.json
{
"extends": [
"@cbnventures/nova/presets/tsconfig/dx-essentials.json",
"@cbnventures/nova/presets/tsconfig/dx-strict.json",
"@cbnventures/nova/presets/tsconfig/fw-expressjs.json"
],
"compilerOptions": {
"baseUrl": "./",
"outDir": "./build",
"rootDir": "./src",
"types": [
"@types/node",
"@types/express"
]
},
"include": [
"./src/**/*"
],
"exclude": [
"./build/**",
"./node_modules/**"
]
}
What This Preset Configures
This preset sets the following compilerOptions.
| Setting | Value | Description |
|---|---|---|
lib | ["ESNext"] | Provides the latest ECMAScript APIs without browser DOM types. |
module | "NodeNext" | Emits ECMAScript module syntax following Node.js module semantics. |
moduleResolution | "NodeNext" | Resolves imports using Node.js ESM resolution, paired with module. |
Related
- Review the layering order in TSConfig Best Practices.
- See how presets compose end to end in the Presets Overview.