tsconfig-extends
raw JSON → 1.0.1 verified Fri May 01 auth: no javascript maintenance
Load TypeScript compiler options from tsconfig.json, fully resolving the "extends" chain. v1.0.1 is the latest stable release (no further updates since 2017). Unlike ts-node or tsc built-in resolution, this is a standalone utility for programmatic usage. It resolves inheritance from both relative paths and node_modules packages. Only provides synchronous API. Minimalist: no caching, no validation beyond what TypeScript enforces. Ships TypeScript declarations. For Node.js >= 4.
Common errors
error TypeError: load_file_sync is not a function ↓
cause CommonJS require without destructuring vs named export
fix
Use import { load_file_sync } from 'tsconfig-extends' or const { load_file_sync } = require('tsconfig-extends');
error Error: Cannot find module 'tsconfig-extends' ↓
cause Package not installed
fix
Run: npm install tsconfig-extends
error SyntaxError: Unexpected token 'export' ↓
cause Using ESM import in a CommonJS environment (Node < 13 or without "type":"module")
fix
Use require() or set "type": "module" in package.json or use dynamic import.
Warnings
gotcha load_file_sync throws if tsconfig.json is missing or invalid JSON / TypeScript config ↓
fix Wrap in try/catch or validate file existence before calling.
gotcha The library does not cache results; repeated calls re-read and re-resolve the entire extends chain ↓
fix Cache result manually if calling multiple times with same path.
deprecated Project is in maintenance mode; no updates since 2017, no support for newer TypeScript features (e.g., references, path mapping from tsconfig) ↓
fix Consider using @typescript-eslint/parser's built-in tsconfig resolution or tsconfig-paths for advanced needs.
Install
npm install tsconfig-extends yarn add tsconfig-extends pnpm add tsconfig-extends Imports
- load_file_sync wrong
const load_file_sync = require('tsconfig-extends').load_file_synccorrectimport { load_file_sync } from 'tsconfig-extends' - load_config_sync wrong
import tsconfig from 'tsconfig-extends'; tsconfig.load_config_sync(...)correctimport { load_config_sync } from 'tsconfig-extends' - TSConfig wrong
import { TSConfig } from 'tsconfig-extends'correctimport type { TSConfig } from 'tsconfig-extends'
Quickstart
import { load_file_sync } from 'tsconfig-extends';
import * as path from 'path';
const tsconfigPath = path.resolve('./tsconfig.json');
try {
const options = load_file_sync(tsconfigPath);
console.log('Compiler options:', options);
} catch (err) {
console.error('Failed to load tsconfig:', err);
}