Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

It's possible to create a callable never #42859

Copy link
Copy link
@mkantor

Description

@mkantor
Issue body actions

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.

Elaborated playground with commentary and more examples

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.