You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem I found can be reproduced with the following code, on typescript version 1.7.5. The problem exists in typescript from the release when class expressions (#497) were introduced.
functionbuilder(){returnnewclassHouse{publicopen():void{console.info('house is open');}}}consthouse=builder();house.open();
is compiled to
functionbuilder(){returnnew(function(){functionHouse(){}House.prototype.open=function(){console.info('house is open');};returnHouse;})();}varhouse=builder();house.open();
and looks good, but throws in the console:
Uncaught TypeError: house.open is not a function
Thats, because from builder() is returned constructor of House instead of an instance. The example above works, when we assign constructor to a variable and then, create instance with the new keyword.
The text was updated successfully, but these errors were encountered:
The problem I found can be reproduced with the following code, on typescript version 1.7.5. The problem exists in typescript from the release when class expressions (#497) were introduced.
is compiled to
and looks good, but throws in the console:
Thats, because from
builder()
is returned constructor ofHouse
instead of an instance. The example above works, when we assign constructor to a variable and then, create instance with thenew
keyword.The text was updated successfully, but these errors were encountered: