Content-Length: 293306 | pFad | https://github.com/microsoft/TypeScript/issues/20007

E4 Function should be assignable to (...args: any[]) => any · Issue #20007 · microsoft/TypeScript · GitHub
Skip to content

Function should be assignable to (...args: any[]) => any #20007

Open
@pelotom

Description

@pelotom

Obviously all functions have type Function. And likewise all functions can be given the type

type AnyFunc = (...args: any[]) => any;

AFAIK, there is nothing one can do with something of type Function that cannot be done with something of type AnyFunc and vice versa. However they are not equivalently assignable:

(f: AnyFunc): Function => f;
(f: Function): AnyFunc => f;
//                        ^
// Type 'Function' is not assignable to type 'AnyFunc'.
//   Type 'Function' provides no match for the signature '(...args: any[]): any'.

If I edit lib.d.ts to add a callable signature to Function:

interface Function {
  (...argArray: any[]): any;
  //...
}

it seems to "fix" this issue; is there any reason not to make this change for real?

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/microsoft/TypeScript/issues/20007

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy