TypeScript Compiler Diagnostics
TS2614: Named import of a default export
The requested name is not exported as a named member and the compiler suggests a default import. This diagnostic is a more specific case than TS2305; it is not emitted for every missing export. Use the matching default import, or change the producer if a named export is part of the intended API. Baseline: TypeScript 5.8.3 with the shown configuration. Diagnose the reported location and nested message before applying a fix; other causes may require a different correction. The first project is intentionally invalid; create the corrected project separately. Neither example requires disabling strict checking.
Formal Syntax & Structure
typescript syntaxtypescript
TS2614 (compiler diagnostic code, not TypeScript syntax)Working Example
Example Snippettypescript
// INTENTIONALLY INVALID — reproduce// File: tsconfig.json (omit this label){ "compilerOptions": { "strict": true, "target": "ES2022", "module": "CommonJS", "types": [], "lib": [ "ES2022", "DOM" ], "noEmitOnError": true, "outDir": "dist" }, "files": [ "main.ts" ]}
// File: main.ts (omit this label)import { scale } from "./dep";console.log(scale(4));
// File: dep.ts (omit this label)export default function scale(n: number) { return n * 2; }
// Run: tsc -p . --pretty false// Expected: TS2614; no emitted main file.
// CORRECTED PROJECT// File: tsconfig.json (omit this label){ "compilerOptions": { "strict": true, "target": "ES2022", "module": "CommonJS", "types": [], "lib": [ "ES2022", "DOM" ], "noEmitOnError": true, "outDir": "dist" }, "files": [ "main.ts" ]}
// File: main.ts (omit this label)import scale from "./dep";console.log(scale(4));
// File: dep.ts (omit this label)export default function scale(n: number) { return n * 2; }
// Run: tsc -p . --pretty false// Expected: no diagnostics.// Run: node dist/main.js// Expected stdout: 8