Add support for static class methods #368
Copy link
Copy link
Open
Description
Describe your feature request here.
Currently, when you define JS like this:
var Term = class {
term;
constructor(term) {
this.term = term;
}
toString() {
return this.term;
}
static fromString(input) {
return new Term(input);
}
};
module.exports = Term;The static method is not available for that class:
import pythonmonkey as pm
Term = pm.require("./term.js")
print(Term.fromString)Will give
Traceback (most recent call last):
File "/test.py", line 4, in <module>
print(Term.fromString)
AttributeError: 'pythonmonkey.JSFunctionProxy' object has no attribute 'fromString'
Code example
No response
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsBacklog
Activity
wiwichips commentedon Jul 2, 2024
Thanks for the bug report @olebedev - we're looking into this
wiwichips commentedon Jul 2, 2024
In the meantime before it's fixed, if you need this behaviour, you can accomplish it through
pm.evalFor example: