Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR TypeError: sweetalert_1.default is not a function #796

Closed
rafatrace opened this issue Jan 31, 2018 · 6 comments
Closed

ERROR TypeError: sweetalert_1.default is not a function #796

rafatrace opened this issue Jan 31, 2018 · 6 comments

Comments

@rafatrace
Copy link

Hi, my sweet alert modal is not showing and I'm getting this error on the console:

ERROR TypeError: sweetalert_1.default is not a function

image

I'm using Angular v5 and SweetAlert 2.1.0.

I'm importing it with the following code:

import swal from 'sweetalert';

And I'm trying to show a simple alert with the following code:

swal("Hello world!");

Any tips?

@rafatrace
Copy link
Author

rafatrace commented Feb 1, 2018

I found the error:

I was importing it like the above code, as the documentation says but I had to import it with the following code:

import * as sweetalert from 'sweetalert';
sweetalert("Hello world!");

I couldnt user "swal" alias for some reason. Typings I guess. This way works fine.

@Jossymelgar
Copy link

image

no me sirve

@Jossymelgar
Copy link

bueno sirve pero me da ese error

@seanmavley
Copy link

Same error. Nothing changes, even with @rafamds approach. His approach gives:

Cannot invoke an expression whose type lacks a call signature. Type 'typeof "/home/khophi/Developments/Angular/PackageToMe/node_modules/sweetalert/typings/sweetalert"' has no compatible call signatures

@lionralfs
Copy link
Collaborator

@seanmavley take a look at #799, this might be a duplicate of that issue.

@seanmavley
Copy link

@lionralfs thanks for pointing out. I was just about to reference that issue in this thread. The #799 solution you presented is working fine here too.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants