Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'constructor' should be allowed as the name of a static member #7475

Closed
DanielRosenwasser opened this issue Mar 11, 2016 · 3 comments
Closed
Labels
ES6 Relates to the ES6 Spec Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it
Milestone

Comments

@DanielRosenwasser
Copy link
Member

The following should be allowed:

class C {
    static constructor() {

    }
}

However, we report an error that a static modifier can't precede a constructor.

After reading through the spec a bit, I think we should reconsider how we wire up constructor in the compiler. It seems as if constructor is not special in any way, and that it simply places a member named constructor on the prototype. See here for more details.

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript ES6 Relates to the ES6 Spec labels Mar 11, 2016
@RyanCavanaugh
Copy link
Member

You just have to write

class Foo {
    static 'constructor'() {

    }
}

This seems preferable to the world of "Why isn't TypeScript invoking my static constructor?"

@mhegazy
Copy link
Contributor

mhegazy commented Apr 26, 2016

related to #442

@bterlson
Copy link
Member

This is maybe understood but while constructor isn't special syntactically, it is special semantically. Eg. Foo.prototype.constructor is just a reference back to Foo, whereas other members are actually installed on Foo.prototype.

@mhegazy mhegazy added this to the TypeScript 2.1 milestone Jun 7, 2016
@mhegazy mhegazy self-assigned this Jun 7, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.1, Future Sep 29, 2016
@RyanCavanaugh RyanCavanaugh added the Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it label Mar 11, 2019
@RyanCavanaugh RyanCavanaugh removed the Bug A bug in TypeScript label Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ES6 Relates to the ES6 Spec Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it
Projects
None yet
Development

No branches or pull requests

4 participants