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 decorators #48

Open
littledan opened this issue Feb 10, 2018 · 6 comments
Open

Constructor decorators #48

littledan opened this issue Feb 10, 2018 · 6 comments

Comments

@littledan
Copy link
Member

Previous discussion: tc39/proposal-decorators-previous#23

Is this OK to leave for v2?

@bmeck
Copy link
Member

bmeck commented Feb 28, 2018

I'd would prefer to leave it for a follow on.

That said, I do like to delete MyClass.constructor somewhat often so it is tempting.

@littledan
Copy link
Member Author

Hmm, we might be able to accommodate that particular case, by putting the constructor property in the elements list (as a "prototype method")... then a @noconstructor class decorator could remove that. Thoughts?

@ljharb
Copy link
Member

ljharb commented Mar 1, 2018

I think for now you could do that with a class decorator, since the class is the constructor function, no?

@littledan
Copy link
Member Author

You mean with a finalizer which deletes the property? Yes, that is possible already, you are right.

@jsg2021
Copy link

jsg2021 commented Mar 1, 2018

@bmeck What does that do? Block the class from being instantiated?

@erights
Copy link

erights commented Mar 1, 2018

With @noconstructor, access to an instance no longer automatically implies access to that instance's constructor. IOW, for @noconstructor class Foo, I can give you access to an instance of Foo while denying you access to the Foo constructor, i.e., to the class object.

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

No branches or pull requests

5 participants