Closed
Description
Bug Report
🔎 Search Terms
call never, callable intersection, intersection call signature, intersection discriminant
🕗 Version & Regression Information
- This changed between versions 3.8.3 and 3.9.7 (and still happens in 4.1.5 and 4.2.0-beta).
⏯ Playground Link
Playground link with relevant code
💻 Code
declare const f: { (x: string): number, a: "" } & { a: number }
const result: "bad" = f()
🙁 Actual behavior
The above code typechecks! f
's type is displayed as never
, but it behaves like (...args: any[]) => any
.
🙂 Expected behavior
f
should either be a real never
(and therefore not be callable), or be callable with the specified call signature ((x: string) => number
). Probably the former?
This occurs when intersecting a type that has a call signature with another incompatible type, and only if the incompatibility involves a literal type (i.e. when it's a discriminant).
Based on the behavior and affected versions, this is likely related to #36696.