sweetalert: Typings error TS2403: Subsequent variable declarations must have the same type.
Upgraded to Angular 7 w/ TypeScript 3.2.4 and am now getting the following whenever I compile:
import swal from 'sweetalert';
swal({ ... });
ERROR in node_modules/sweetalert/typings/sweetalert.d.ts(4,9): error TS2403: Subsequent variable declarations must have the same type. Variable ‘swal’ must be of type ‘typeof import(“C:/Projects/me/browser/node_modules/sweetalert/typings/sweetalert”)’, but here has type ‘SweetAlert’.
If I edit node_modules/sweetalert/typings/sweetalert.d.ts from…
import swal, { SweetAlert } from "./core";
declare global {
const swal: SweetAlert;
const sweetAlert: SweetAlert;
}
export default swal;
export as namespace swal;
… to …
import swal, { SweetAlert } from "./core";
export default swal;
export as namespace swal;
… it starts working.
Any ideas?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 26
- Comments: 25
Commits related to this issue
- Fix Type Error on swal Fixes #890 ``` ERROR in node_modules/sweetalert/typings/sweetalert.d.ts(4,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'swal' must... — committed to doggy8088/sweetalert by doggy8088 5 years ago
- Fix Type Error on swal Fixes #890 ``` ERROR in node_modules/sweetalert/typings/sweetalert.d.ts(4,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'swal' must be ... — committed to doggy8088/sweetalert by doggy8088 5 years ago
- Fix Type Error on swal Fixes #890 ``` ERROR in node_modules/sweetalert/typings/sweetalert.d.ts(4,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'swal' must be ... — committed to doggy8088/sweetalert by doggy8088 5 years ago
- Fix Type Error on swal Fixes #890 ``` ERROR in node_modules/sweetalert/typings/sweetalert.d.ts(4,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'swal' must be ... — committed to doggy8088/sweetalert by doggy8088 5 years ago
- Fix Type Error on swal Fixes #890 ``` ERROR in node_modules/sweetalert/typings/sweetalert.d.ts(4,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'swal' must be ... — committed to doggy8088/sweetalert by doggy8088 5 years ago
- fix: remove exported namespace to prevent Typings error TS2403 https://github.com/t4t5/sweetalert/issues/890 — committed to AlbinoDrought/sweetalert-sans-ts-namespace by AlbinoDrought 5 years ago
- fix: remove exported namespace to prevent Typings error TS2403 https://github.com/t4t5/sweetalert/issues/890 — committed to AlbinoDrought/sweetalert-sans-ts-namespace by AlbinoDrought 5 years ago
- Update sweetalert.d.ts resolving issue https://github.com/t4t5/sweetalert/issues/890 — committed to andreibastos/sweetalert by andreibastos 5 years ago
Hi all,
Save yourself the effort and use sweetalert 2 https://sweetalert2.github.io/
I think this line have to removed:
https://github.com/t4t5/sweetalert/blob/bfd0e63e4157e67b36d1858a6721b0f592ba5338/src/sweetalert.d.ts#L4
@bogdan-calapod Here’s what I have been doing as a workaround, so that our CI build doesn’t fail:
sweetalert.min.js).sweetalert.min.jsinsrc/assets/scriptsin Angular application.src/assets/scripts/sweetalert.min.jstoscriptsentry inangular.jsondeclare var swal: any;above the class declaration.swal, i.e.return swal({...})npm uninstall sweetalert --saveI fixed this by overriding the sweetalert types. I added a file in the src dir named
src/node_modules/sweetalert/index.d.tsAny idea on a workaround apart from editing the definition file manually? It’s becoming a bit of a hassle remembering to do that after every clone / npm install.
Same issue, same situation.
However, I noticed that just commenting out the line
export as namespace swal;also lets it compile. I’ve been looking at the TypeScript changelogs for any clues…Solved it by changing this line:
to:
or (with the interface):