Typescript: Could not find a declaration file for module 'sweetalert2/dist/sweetalert2.js'.
See original GitHub issueCurrent behavior
TS giving that message above.
My TS config
{
"compilerOptions": {
"target": "esnext",
"strict": true,
"noEmit": true,
"module": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"typeRoots": [
"./node_modules/@types",
"./js/types"
]
},
"exclude": ["node_modules", "**/*.spec.ts"]
}
SweetAlert version: 9.7.1 Typescript version: 3.7.5
Expected behavior
Module shoud find declaration file even in dist and src folders
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Could not find a declaration file for module 'module-name ...
In Node.js everything works fine, but TypeScript: import {Injector} from '@ts-stack/di' ...
Read more >Could not find declaration file for module 'X' Error | bobbyhadz
The error "Could not find a declaration file for module" occurs when TypeScript cannot find the type declaration for a module. To solve...
Read more >How to fix error TS7016: Could not find a declaration file for ...
How to fix error TS7016: Could not find a declaration file for module 'XYZ'. 'file.js' implicitly has an 'any' type · Try `npm...
Read more >Fixing the TS7016 Error | Atomist Blog
Could not find declaration file -- How do you get past the TS7016? ... When I import a JS module that is not...
Read more >Using SweetAlert2 with TypeScript, cou.. - W3coded.com
Using SweetAlert2 with TypeScript, could not find a declaration file for module sweetalert2distsweetalert2.js javascript,sweetalert2,module,file,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve found solution. I added
mainFields: ['module', 'browser', 'main']
field in my webpack config, because in your lib’s package.json you have this line -module": "src/sweetalert2.js"
Thanks for the repo @nixta purplecandle!
The reason is that you’re setting
"strict": true
in yourtsconfig
. Add"noImplicitAny": false
or any other solution from https://github.com/microsoft/TypeScript/issues/15031The behavior doesn’t make much sense to me as well as to many commenters from https://github.com/microsoft/TypeScript/issues/15031 but it is what it is 🤷♂️