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

Exported classes should be extendable from JavaScript #153

Open
kazuho opened this issue May 3, 2013 · 3 comments
Open

Exported classes should be extendable from JavaScript #153

kazuho opened this issue May 3, 2013 · 3 comments

Comments

@kazuho
Copy link
Member

kazuho commented May 3, 2013

As @shibukawa suggested, exported classes should be extendable by using ordinary JavaScript.

note: the example right below is known not to work, for the current proposal see #153 (comment)

// in foo.jsx
__export__ class Base {
    function say() : void {
        log "base";
    }
}
// in JavaScript
var Base = JSX.require("foo.jsx").Base;
function Derived() {
}
Derived.prototype = new Base;
Derived.prototype.say = function () {
    log "derived";
};
kazuho added a commit that referenced this issue May 3, 2013
kazuho added a commit that referenced this issue May 3, 2013
…wing that #153 is impossible unless by providing a helper function for the purpose
@kazuho
Copy link
Member Author

kazuho commented May 3, 2013

Sorry to change my words but it is impossible to extend a JSX class using ordinary JavaScript (see the example in prev. comment; the method say belonging to an instance is sometimes known to be __export__ed and sometimes not). We need to provide a helper function.

@kazuho
Copy link
Member Author

kazuho commented May 3, 2013

The helper function for extending JSX classes in JavaScript may look like follows:

var Base = JSX.require("foo.jsx");

var Derived = Base.$extend({
    constructor: function () {
        ...
    },
    toString: function () {
        ...
    },
});

@gfx
Copy link
Member

gfx commented May 5, 2013

+1 for helper function

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

2 participants