镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Suggestion: callable class #183

Description

class MyCallableClass {
   property: string;
   constructor() {
     //constructor body
   }
   (): MyCallableClass { // could be 'string' or any other type
     // call signature body
     return new MyCallableClass();
   }
}

would emit :

function MyClass() {
  if (this instanceof MyClass) {
    //constructor body
  } else {
    // call signature body
    return new MyCallableClass();
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions