Base tsconfig for Foxglove projects.
- TypeScript v5.8+
yarn add -D @foxglove/tsconfigChoose the config that matches your environment:
Uses module: "NodeNext", which enforces Node.js ESM rules.
Use node.json for published libraries, even if your library will be used in bundled apps. Bundlers consume Node-style packages natively, just remember to avoid Node-specific APIs like fs or process.
Relative imports must include explicit file extensions (e.g., import { foo } from "./bar.ts").
{
"extends": "@foxglove/tsconfig/node.json",
"include": ["./src/**/*"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
}
}Tip
base.json uses target: "ESNext". For published libraries, you may wish to set a lower target (e.g., "ES2022" for Node 18).
Uses module: "Preserve", which enables optimizations for code consumed directly by a bundler.
Supports extensionless relative imports (e.g., import { foo } from "./bar").
{
"extends": "@foxglove/tsconfig/bundler.json",
"include": ["./src/**/*"],
"compilerOptions": {
"noEmit": true,
"lib": ["ESNext", "DOM"]
}
}Provides strict type-checking and modern defaults, but no module or moduleResolution settings. Use this when node.json and bundler.json don't fit your environment:
{
"extends": "@foxglove/tsconfig/base.json",
"compilerOptions": {
"module": "...",
"moduleResolution": "..."
}
}tag=$(npm version minor) && echo "$tag"
git push && git push origin "$tag"