-
Notifications
You must be signed in to change notification settings - Fork 103
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
callable classes #283
Comments
👍 |
No objections under the premise that the feature will be limited to Besides, I believe that the attribute should be named |
Another idea is that use anonymous method to check this kind of attribute, see class nock {
static function (url : string) : scope;
} = "require('nock')"; Fundamentally there's no difference between the semantics, only the syntaxes differ. From the aspect of extensibility I prefer |
@wasabiz IMO we should support definitions like below.
In the above snippet, |
According to @yosuke-furukawa san, something like python's
__call__
method (that's for objects, and in this case for classes) will be useful if introduced.Many nodejs modules (ex. https://github.com/flatiron/nock) are providing a kind of tricky API, that is a function object which returns new instances every time it's called. They are alternative style of class and JSX doesn't have a means of getting access to these functions.
I suggest JSX introduce a special method called
__new__
, which enables users to call classes directly as if it is an object.The text was updated successfully, but these errors were encountered: