I'm migrating one of my projects to TypeScript, in that project SweetAlert2 library is used.
The default way to import SweetAlert2 (both JS and CSS) is
import Swal from 'sweetalert2'
This works fine with TypeScript because there are types in the library: https://github.com/sweetalert2/sweetalert2/blob/master/sweetalert2.d.ts
But in my project the way of importing is this:
import Swal from 'sweetalert2/dist/sweetalert2.js'
This is import for JS only, without styles. With this type of import, I'm getting the TS error:
Could not find a declaration file for module 'sweetalert2/dist/sweetalert2.js'.
ts(7016)
I tried to copy sweetalert2/sweetalert2.d.ts
to sweetalert2/dist/sweetalert2.d.ts
, but got another error:
File 'node_modules/sweetalert2/dist/sweetalert2.d.ts' is not a module.
ts(2306)
What's going on here and why TS complains about dist/sweetalert2.d.ts
is not a module?
limonte/swal-ts
. Thanks! – Brannen