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

Support this pseudo-params in classes, and enforce subtyping on structural class statics #1761

Closed
wants to merge 10 commits into from

Conversation

popham
Copy link
Contributor

@popham popham commented May 8, 2016

This patch adds support for a this pseudo-param on class methods (static and non-static). With the syntax someMethod(this: this & I,... users can impose requirement beyond "is subtype of the enclosing class," the current behavior. Some goofiness becomes admissible too, e.g. someMethod(this: {})--just don't be goofy (maybe a warning is warranted if the pseudo-param's type is not a subtype of the enclosing class). I have a use case where the value in this extension lies in chaining of static methods, not non-statics, so I've extended class subtyping to structural class statics (InstanceT ~> SuperT still ignores subtyping of statics). I feel like I'm on solid ground after a chat with @jeffmo and @avikchaudhuri on IRC, although during that discussion I forgot to contrast ES5 and Node inheritance against ES6 inheritance. I recall in the past that @samwgoldman and I disagreed on whether class statics should subtype.

Node's inheritance (util.inherit) and the ad hoc inheritance of ES5 (SomeClass.prototype = Object.create(ParentClass.prototype, {...}) without SomeClass.proto = ParentClass) do not chain class statics. Subtyping statics is biased toward ES6 inheritance, whereas the status quo is biased toward Node and ad hoc inheritance.

Closes #807, #1369, #1704, #1705

@ghost ghost added the CLA Signed label May 8, 2016
@popham
Copy link
Contributor Author

popham commented May 12, 2016

New PR for rebase

@popham popham closed this May 12, 2016
@goodmind goodmind added the Superseded PRs that solve the same issue as a "superseding" PR that already landed label Jul 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Superseded PRs that solve the same issue as a "superseding" PR that already landed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abstract class support
2 participants