I started an ionic 2 project and one of the few things I don’t like is the relative paths. I read some documentation from typescript and I modified the tsconfig.json file, and seems like the modifications I do are not taking any effect in the ionic app (but are working in typescript).
I validated that my changes to tsconfig.json are correct since calling “tsc --traceResolution” tells me the resolution is working. But once I launch the ionic app I get the “Cannot find module” error.
Example
In case anyone is interested in reproducing the issue, create a brand new ionic 2 project, modify tsconfig.json by adding the following to compilerOptions:
"baseUrl": "./src",
Then create the file src/foo.ts with the contents:
export class Foo {}
finally add the following to app.module.ts:
import { Foo } from 'foo';
new Foo();
As far as I understand that should work, it doesn’t and for it to work it is necessary to have the following (which I want to avoid):
Incase someone is having similar trouble to figure what exact changes you need to make get this working. I have posted my answers for this problem here :