TypeScript Compiler Options
allowSyntheticDefaultImports — TypeScript compiler option
Allows default-import syntax for certain modules without a declared default export. Does not itself change JavaScript emission or add a runtime wrapper. A compiler-accepted default import can fail during execution. Default (5.8.3): mode-dependent; false in tested CommonJS configuration without interop. Create the labeled files in an isolated project and run tsc -p tsconfig.json. No diagnostics; output: none. Local project fixture, not a single-file editor.
Formal Syntax & Structure
typescript syntaxtypescript
{ "compilerOptions": { "allowSyntheticDefaultImports": true }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| allowSyntheticDefaultImports | boolean | Set in compilerOptions; default: mode-dependent; false in tested CommonJS configuration without interop. |
Working Example
Example Snippettypescript
// File: tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "noEmitOnError": true, "noEmit": true, "esModuleInterop": false, "allowSyntheticDefaultImports": true }, "files": [ "main.ts", "dep.ts" ]}// File: main.tsimport double from "./dep";console.log(double(4));// File: dep.tsfunction double(n: number) { return n * 2; }export = double;