Comments (7)
if i read the spec (I am not sure if I read the wrong part) it looks like its is possible
https://tc39.es/ecma262/#sec-runtime-semantics-classdefinitionevaluation
in 5e it says "If superclass is null, then" and MDN also still says "The .prototype of the extension must be an Object or null."
Do I read those wrong?
from katas.
though i dont get it work anywhere neither, here chrome (canary) console
> class A extends null {}
undefined
> new A
VM79:1 Uncaught TypeError: Super constructor null of A is not a constructor
at new A (<anonymous>:1:1)
at <anonymous>:1:1
and node repl
> class A extends null {}
undefined
> new A
Uncaught TypeError: Super constructor null of A is not a constructor
at new A (repl:1:1)
from katas.
yeah the only useful thing to learn is what you described. But not really of any practical value, is it?
So I would rather change this test to verify that a parent must be callable with super()
and since null
has no super it throws. Does that makes sense?
it('a class extending `null` can not be instantiated, since calling `super()` on null fails', () => {
class NullClass extends null {}
assert.throws(() => new NullClass);
});
like this
from katas.
I'm not really sure. Wouldn't that be kind of misleading new developers to assume that a class
may extend null
?
We should either remove the whole test or explain the rationale behind the use-case. And also somehow probably document somewhere ( in the test itself ) that this is a gray-area test.
Do I read those wrong?
No, what you're reading is correct. The spec was first made to extend null, but then apparently many bad things happened and they reverted it ( see links in issue description )
I found this question on StackOverflow that questions this use-case altogether. The question has different errors of this use-case not working
PS : the issue title is probably misleading, what I meant was that it was broken by ECMAScript and that it wasn't our fault.
from katas.
i agree, either 1) remove the test or 2) make it more explicit, maybe like that:
it('`extends null` is not supported', () => {
class NullClass extends null {}
assert.throws(() => new NullClass);
});
just to mention the edge case and its solution.
What do you think?
from katas.
actually, it is supported by the spec, it's just not working as intended. So, maybe, the test should be extends null
is broken or something along those lines maybe?
from katas.
the MDN revision used the term 'not allowed', so, I guess 'not supported' is close enough. I'd favor 'not allowed' though.
from katas.
Related Issues (19)
- Kata "Destructuring":"rename":"rename object key" is green right away HOT 2
- Kata 34: Symbol HOT 1
- Shorter version of kata 51 "generator:yield" test case #2 HOT 8
- Rest in destructuring HOT 11
- Renaming in destructuring HOT 3
- Misprint in the test HOT 1
- Incorrect values in arrows kata HOT 3
- ES6 Kata 69 "Reflect - defineProperty" kata needs updating HOT 4
- Solution for Kata 40 freezes the browser tab HOT 1
- Kata 76 - Promise Creation - doesn't wrok in TDDbin HOT 5
- Object.is
- Kata 28 - TDDbin add indentation to super.constructor HOT 2
- Is it OK to move CHANGELOG.md into separate issues? HOT 2
- Two tests in Promises already green when starting
- Build issue HOT 2
- Question about what to fix in parseInt HOT 3
- template repository to fork and learn HOT 8
- xdomain vendoring HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from katas.