TypeError: Class constructor Recenter cannot be invoked without 'new'

3317
2
Jump to solution
11-26-2020 03:21 AM
MassimilianoGeppi
Esri Contributor

Hi,

I'm following this "Custom Widget" sample from

https://developers.arcgis.com/javascript/latest/sample-code/widgets-custom-recenter/index.html#1c

But when i try to run this example in chrome i'm getting ths error:

(index):198 Uncaught (in promise) TypeError: Class constructor Recenter cannot be invoked without 'new'
at new d ((index):198)
at index.html:69

I've notice that if i replace the "js" generated from my tsc with js in the example everything run correctly.

In attach its possible to see my Recenter.js generated after Recenter.tsx compilation.
(It's possible to see the difference with the original in the example)

during compilation, everything is succesfully done.

(I've the latest version of Node and Typescript)
Is there any incompatibility with the versions?

Thank you in advance.

m.

 

0 Kudos
1 Solution

Accepted Solutions
MassimilianoGeppi
Esri Contributor

Great!!!

I've solve my problem.

Thank you Adam

 

 

 

View solution in original post

0 Kudos
2 Replies
AdamLabruyere
New Contributor

I ran into the same problem. To fix it for me I used compilerOptions.target = "es5" in the tsconfig.json. To allow the tsc command to compile to es5 I also needed to install @types/node. Hope that helps.

Cheers

Adam

MassimilianoGeppi
Esri Contributor

Great!!!

I've solve my problem.

Thank you Adam

 

 

 

0 Kudos