Closed
Description
TypeScript Version: 3.5.2
Search Terms:
Code
constructor(options = {}) {
console.log('hello')
super(options)
}
Expected behavior:
It should work. It's valid JavaScript.
Run the following in Chrome console (or one that support class fields):
class A {
foo = 'foo'
constructor() {
this.foo = 'bar'
}
}
class B extends A {
bar = 'bar'
constructor() {
console.log('hello')
super()
this.bar = 'foo'
}
}
new B()
Actual behavior:
It complains:
A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
Playground Link:
Related Issues: