TypeScript Compiler Diagnostics
TS2769: No matching overload
A call must match a visible overload signature. An implementation signature is not a public fallback. Here boolean matches neither overload; the correction calls with supported input types. If a new input is intended, add a supported overload and implement it, rather than casting. 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
TS2769 (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)function convert(v: string): number;function convert(v: number): string;function convert(v: string | number) { return typeof v === "string" ? v.length : String(v); }console.log(convert(true));
// Run: tsc -p . --pretty false// Expected: TS2769; 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)function convert(v: string): number;function convert(v: number): string;function convert(v: string | number) { return typeof v === "string" ? v.length : String(v); }console.log(convert("abc"), convert(4));
// Run: tsc -p . --pretty false// Expected: no diagnostics.// Run: node dist/main.js// Expected stdout: 3 4