Skip to content

Suggestion: callable class #183

@fdecampredon

Description

@fdecampredon
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();
  }
}

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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions