Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upallow calling class constructor as a function(without new) #321
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
meandmycode
Jan 23, 2016
Well, B is trying to extend A which is no longer a class after calling abstract but a function.. if you really want to do this, you could do the following:
function abstract(target) {
return class cls extends target {
constructor(...args) {
if (new.target === cls) {
throw new Error('instantiating abstract class is disallowed');
}
super(...args);
}
}
}
meandmycode
commented
Jan 23, 2016
|
Well, B is trying to extend A which is no longer a class after calling
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zenparsing
Jan 23, 2016
Contributor
This question is not appropriate for this repository. Please move this to the es-dicuss mailing list (and try looking at the archives as well).
|
This question is not appropriate for this repository. Please move this to the es-dicuss mailing list (and try looking at the archives as well). |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
domenic
Jan 23, 2016
Member
Yes, please ask help questions on Stack Overflow or es-discuss. See https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md for what is acceptable to post to this repository.
|
Yes, please ask help questions on Stack Overflow or es-discuss. See https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md for what is acceptable to post to this repository. |
disjukr commentedJan 23, 2016
es2015 says "If F’s [[FunctionKind]] internal slot is "classConstructor", throw a TypeError exception."
but i don't know why.
i just wanted to make abstract class decorator using babel:
call constructor proposal seems can't solve my problem.