Ionic 7.0.0, Angular 15.2.4. "ionic generate page auth" results in "TS2304: Cannot find name 'async'." error in file "" file


Exactly what it says. I’m running Ionic 7 and Angular 15.2.4. I’ve generated a brand-new project using "ionic start." I select Angular as my framework, and the Ionic project type is "blank." The project generates fine.

In the terminal in my IDE, in this brand-new project with absolutely nothing else added to it, I type ionic generate page auth and press Return. The page seems to generate fine, but then my IDE gives me a TS2304: Cannot find name 'async'. error in the file.

(BTW: If I ignore this and continue to generate pages, it continues to give me this error in every new page I generate — the {pagename}.page.spec.ts shows this error in every page.)

Here’s a screenshot of my IDE. You can see the error on line 8:
Screenshot of IDE showing error in file

Is there maybe a bug in Ionic 7? Is there something I need to update elsewhere? The last time I ran anything in Ionic, I was told to update Ionic by typing npm i -g @ionic/cli which I did… That was yesterday… And now, today, this is happening…

How do I fix this problem?


Well, I got it to stop giving me the error message by adding async to the import line at the top of the file.

So that line now looks like this:

import { async, ComponentFixture, TestBed } from '@angular/core/testing';

Apparently async is deprecated, replaced by waitForAsync but I’m not going to bother to learn how to use that. As long as this thing compiles and runs now, I’m good.

Answered By – Laurence MacNeill

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published