I have written a widget using JS API 4.16/TypeScript and I'm deploying it in another application (also using TypeScript) and I'm getting the error in the post title on compile. In index.html I have:
and in my main.ts I have (this is the line generating the error):
the error is the same as the title: Cannot find module or its corresponding type declarations.ts(2307)
my tsconfig is:
the file structure is:
/
..my-app/
.. ..app/
.. .. ..main.ts
.. ..index.html
.. ..tsconfig.json
..Widgets/
.. ..MyWidget/
.. .. ..app/
.. .. .. ..MyWidget.ts .js etc
How can I resolve this error? There's a lot of info on developing custom widgets, but not much on deploying/moving to production, so I'm looking for any tips on the best way to do that, too.
It looks like the order is incorrect in this line:
import MyWidget = require("my-widget/MyWidget");
Should be something like this:
import MyWidget = require("MyWidget/my-widget");
Here are some examples about this workflow from our samples page:
Thanks for the reply. I've tried using the order you suggested and it results in the browser trying to load my widget from the js api, and generating a not found error.
From DevTools console:
GET https://js.arcgis.com/4.16/dojo/MyWidget/my-widget.js 404
Using the original order, the code still compiles and loads properly in the browser. That made me think it was a problem with my TypeScript configuration.