[Solved] New Project: Invalid imports are replaced with "any"



This might be a dumb question, and I apologise if it is. It’s late and I’m tired and hoping there might be an answer in the morning :stuck_out_tongue:

I’m updating an app from beta 11 to 2.0.0. I started a new project, then copied all my source files over into src.

Some of my paths have changed now (I was tidying up as part of the move), so I need to go through and update all the “import” statements to point to the new relative paths.

I’m using VS Code.

Now here is my possibly dumb question:

I think I used to get errors if the path was wrong and VS Code would underline it red. “Cannot find module ‘./my/wrong/path’” or something like that.

But in this new ionic project I don’t get those errors. It seems to have just assumed it as “any”, which sometimes causes compiler errors (eg. using it to declare the type of a method parameter), but other than that it just ignores it.

How can I get it to tell me the path is wrong?, it’s going to drive me nuts!


import { MyClass } from './invalid/path';

This is not giving me an error, it is just assuming MyClass as any

How can I get it like it used to be?

Thank you :slight_smile:


If anyone else hits this, it is because of the wildcard module declaration that is in the new starter project. I didn’t see it there.

declare module '*';

Just remove it.

I understand the logic behind putting it there, so you can use 3rd party libs without type declarations, but it inadvertently cripples a lot of the safety of having the typescript compiler for most cases. I could quite easily make a simple spelling mistake on an import and not know it until I get a runtime error that my variable is undefined.

So I think this option should not be enabled by default.

Ionic 2 Importing Providers - Cannot find name