# \[js-es6\]Must call \`super()\` constructor before accessing \`this\` in classes derived from an extern class with constructor

**URL:** <https://community.haxe.org/t/js-es6-must-call-super-constructor-before-accessing-this-in-classes-derived-from-an-extern-class-with-constructor/2870>\
**Category:** Haxe\
**Tags:** haxe-js\
**Created:** [January 29, 2021, 7:37am UTC](https://community.haxe.org/t/js-es6-must-call-super-constructor-before-accessing-this-in-classes-derived-from-an-extern-class-with-constructor/2870 "2021-01-29T07:37:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhan](https://community.haxe.org/user_avatar/community.haxe.org/zhan/32/468_2.png) [@Zhan](https://community.haxe.org/u/Zhan)\
**Post date:** [January 29, 2021, 7:37am UTC](https://community.haxe.org/t/js-es6-must-call-super-constructor-before-accessing-this-in-classes-derived-from-an-extern-class-with-constructor/2870/1 "2021-01-29T07:37:08Z")

</div>

[js]Must call `super()` constructor before accessing `this` in classes derived from an extern class with constructor

`-D js-es=6`

I found [this issue](https://github.com/HaxeFoundation/haxe/issues/7869) already close, but I still got this error in haxe 4.1.5.

```haxe
@:native("cc.Component") extern class Component {
	function new();
}

class Main extends Component {

	public function new() {
		super();
		trace('ok');
	}

}

```

---

<div class="post-metadata">

**Author:** ![RealyUniqueName](https://community.haxe.org/user_avatar/community.haxe.org/realyuniquename/32/10_2.png) [@RealyUniqueName](https://community.haxe.org/u/RealyUniqueName)\
**Post date:** [January 29, 2021, 2:09pm UTC](https://community.haxe.org/t/js-es6-must-call-super-constructor-before-accessing-this-in-classes-derived-from-an-extern-class-with-constructor/2870/2 "2021-01-29T14:09:44Z")

</div>

I can’t reproduce the error neither with 4.1.5 nor with the development version of Haxe.

---

<div class="post-metadata">

**Author:** ![Zhan](https://community.haxe.org/user_avatar/community.haxe.org/zhan/32/468_2.png) [@Zhan](https://community.haxe.org/u/Zhan)\
**Post date:** [January 30, 2021, 7:40am UTC](https://community.haxe.org/t/js-es6-must-call-super-constructor-before-accessing-this-in-classes-derived-from-an-extern-class-with-constructor/2870/3 "2021-01-30T07:40:10Z")

</div>

```haxe
@:native("cc.Component") extern class Component {

    function new();

}

class Main extends Component {

    public var dd:Array<Int>=[];

    public function new() {

        super();

        trace('ok');

    }

    public static function main() {

        

    }

}

```

@RealyUniqueName after add

```haxe
 public var dd:Array<Int>=[];

```

---

<div class="post-metadata">

**Author:** ![Confidant](https://community.haxe.org/user_avatar/community.haxe.org/confidant/32/63_2.png) [@Confidant](https://community.haxe.org/u/Confidant)\
**Post date:** [August 23, 2024, 4:27pm UTC](https://community.haxe.org/t/js-es6-must-call-super-constructor-before-accessing-this-in-classes-derived-from-an-extern-class-with-constructor/2870/4 "2024-08-23T16:27:37Z")

</div>

I have the same issue. Haxe 4.2.5.

---

<div class="post-metadata">

**Author:** ![Confidant](https://community.haxe.org/user_avatar/community.haxe.org/confidant/32/63_2.png) [@Confidant](https://community.haxe.org/u/Confidant)\
**Post date:** [August 23, 2024, 4:39pm UTC](https://community.haxe.org/t/js-es6-must-call-super-constructor-before-accessing-this-in-classes-derived-from-an-extern-class-with-constructor/2870/5 "2024-08-23T16:39:26Z")

</div>

I was able to [reproduce the error here](https://try.haxe.org/#360F8756). (Haxe 4.3.6) It seems it only comes when DCE is set to “no”.

---

<div class="post-metadata">

**Author:** ![Confidant](https://community.haxe.org/user_avatar/community.haxe.org/confidant/32/63_2.png) [@Confidant](https://community.haxe.org/u/Confidant)\
**Post date:** [August 23, 2024, 4:48pm UTC](https://community.haxe.org/t/js-es6-must-call-super-constructor-before-accessing-this-in-classes-derived-from-an-extern-class-with-constructor/2870/6 "2024-08-23T16:48:08Z")

</div>

In my own project the error happens regardless of DCE setting. I finally got it to compile by removing the “new” function from the extern and the super() calls. Not sure if it will run properly yet.
