I have a project written in TypeScript v.1.4 "ECMA6" and I want to use 'async' only because of some calculations needed to be asynchronous.
But after I upgrade my TypeScript version to 1.8 in Visual Studio 2013, I got big problems with extended classes and I have no idea why?
The exception I get is:
Class constructor "XYZ"cannot be invoked without 'new'
The classes looks like a extend b, b extend c...
class XavObject {
constructor() { }
}
class XavWidget extends XavObject {
constructor(control: JQuery, name?: string, id?: number) {
super();
}
}
class Widget_ConstructionKitContainer extends XavWidget {
constructor(control: JQuery, controlName: string) {
super(control, controlName, 1); // ---> here throws the exception
}
}
Why does this exception occur and what can I do to resolve it?
EDIT: I try to give more information...
I have a webservice written in C# which makes the .js-Files from the .ts-Files accessible. Something like "http://localhost:8080/DLLName/XavObject.js"
So that the HTML looks like:
<script src="XavObject.js"></script>
<script src="XavWidget.js"></script>
<script src="Widget_ConstructionKitContainer.js"></script>
<script>
xavManager.jQuery(document).ready(function () {
var constructionKitContainer =
new Widget_ConstructionKitContainer(
xavManager.jQuery('#ConstructionKitContainer'),
"ConstructionKitContainer",
xavManager.jQuery('#regionSelector'),
xavManager.jQuery('#regionConfigurator'),
xavManager.jQuery('#regionContainer'),
xavManager.jQuery('#Preview'),
xavManager.jQuery('#ThreeDContainer'),
xavManager.jQuery('#MainThreeD'),
xavManager.jQuery('#NavThreeD'),
[xavManager.jQuery('#ModelTypAuswahl'),
xavManager.jQuery('#ModelformAuswahl'),
xavManager.jQuery('#WandArtikelAuswahl'),
xavManager.jQuery('#EbeneAuswahl'),
xavManager.jQuery('#ElementAuswahl'),
xavManager.jQuery('#MaterialAuswahl'),
xavManager.jQuery('#SetArtikelAuswahl'),
xavManager.jQuery('#GriffArtikelAuswahl')],
constanten
);
});
</script>
After I call the page, the last script is executed and throws the exception.
The Structure of the Project looks like:
So the three Classes are in three Files and two of them in the same library, the other one in another.
EDIT Part2:
After I have restarted my pc this error message disappears ... But another Error in some js-File appears....
Syntax Error ONLY IN JS-FILE
He can't compile one File
class SelectionRules extends ValidationRules {
protected _getNewTimedOutObject(): ValidationRules_TimeoutItem_Calculate|SelectionRules_TimeoutItem_Calculate {
return new SelectionRules_TimeoutItem_Calculate();
}
}
class SelectionRules_TimeoutItem_Calculate extends ValidationRules_TimeoutItem_Calculate {
public liElement: HTMLElement;
}
class ValidationRules_TimeoutItem_Calculate {
public Timeout: number;
public Setting: Widget_ConfiguratorBase_Object_Setting;
public SearchString: string;
public ErrorText: string;
public Value: string = "";
public DataElement: Widget_Article_Setting;
public ContainerEntryIndex: number;
}
Is it because of this part?
ValidationRules_TimeoutItem_Calculate|SelectionRules_TimeoutItem_Calculate
But why does these lines work with TypeScript 1.4?
After tons of hours i got it....
After you upgraded TypeScript, restart Visual-Studio! If you work with ECMA6 and you Double Typed like Parameter/Functions like ValidationRules_TimeoutItem_Calculate|SelectionRules_TimeoutItem_Calculate you need to Change the solution-options back to ECMA5 same issue with new generated Classes! --> back to ECMA5 it will work after compile these everything work