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:
window.dojoConfig = {
packages: [
{
name: "my-widget",
location: "/Widgets/MyWidget/app"
}
]
};
and in my main.ts I have (this is the line generating the error):
import MyWidget = require("my-widget/MyWidget");
the error is the same as the title: Cannot find module or its corresponding type declarations.ts(2307)
my tsconfig is:
{
"compilerOptions": {
"esModuleInterop": true,
"module": "amd",
"noImplicitAny": true,
"sourceMap": true,
"jsx": "react",
"jsxFactory": "tsx",
"target": "es5",
"lib": ["es5", "es6", "dom", "scripthost"],
"experimentalDecorators": true,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
"include": ["./app/*"],
"files":[
"./node_modules/dojo-typings/dojo/1.11/modules.d.ts",
"./node_modules/dojo-typings/dijit/1.11/modules.d.ts",
"./node_modules/dojo-typings/dojox/1.11/modules.d.ts"
],
"exclude": ["node_modules"]
}
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.