Ionic2: Toast is not included in 'ionic-angular' anymore?


#1

Hi all
I’m working on the latest Ionic 2 version (Currently 2.0.0-beta.31) and from some reason, I can not import Toast to my project:

import {NavController, Toast} from ‘ionic-angular’;

Toast here is undefined (Error: … no exported member ‘Toast’) on import, even before I have used it in my code, is it no longer supported?

Here is what happen when I’m trying to use it anyway (as expected, since its not imported):

const toast = Toast.create({
      message: 'This is your Toast message...',
      showCloseButton: true,
      closeButtonText: 'Ok'
    });
    this.nav.present(toast);

Error:
TypeError: Cannot read property ‘create’ of undefined
at MiscellaneousPage.showToast

as you can see here, my text editor show this error once I have added it:

Thank you.


#2

It’s still there. I would recommend reading the changelogs and upgrade guides and see if you missed something during an upgrade process that left your setup broken somehow.


#3

weired, since everything else is working great, Ill check it and update (Ill install ion2 from scratch and import it).
Thanks anyway.


#4

you right, I had Typescript errors, That’s why it did not build me project, Thanks for the tip.


#5

If it’s not on by default, I strongly recommend enabling noEmitOnError (and noImplicitAny) to your tsconfig.json. Lots of things that used to be frustrating runtime problems instantly become caught at build-time.


#6

I just buid a new ion2 project and moved all files to the new project, And there, It is by default :), Now I have to fix all my errors, but I think its great (Thats the way it should be) :wink:
Thanks again!