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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy