Skip to content

Regression causes Function top-type to be callable with no argumentsΒ #48840

Closed
@webstrand

Description

@webstrand

Bug Report

πŸ”Ž Search Terms

function top type callable spread never regression

πŸ•— Version & Regression Information

  • This changed between versions 3.8.3 and 3.9.7

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

declare let foo: (...args: never) => void;
foo = (x: string) => {};
foo();  // no error

πŸ™ Actual behavior

foo() was permitted.

πŸ™‚ Expected behavior

foo() should not be permitted because it is unsafe. (...args: never) => unknown behaves as the top-type for all functions; all function types are assignable to it. So calling it will lead to unsafe behavior by functions expecting 1 or more arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-repros

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions