I'm working on an angular 2 project written in TypeScript 2 and i'm currently facing an issue with the imports mechanism.
Every sub-folder of my project has an "index.ts" file inside, that is exporting classes the said folder contains.
So, in my "app" directory, I have
- app.component.ts
- app.module.ts
- app.routes.ts
And then, an index.ts file containing :
export * from './app.component';
export * from './app.module';
export * from './app.routes';
My issue is that I'm not able to import the exported classes from a file that is located in this same directory.
E.g., in my app.module.ts, I want to import the app component. If I do :
import { AppComponent } from './app.component';
Everything work fine ! No error at compile time and runtime. Life is cool, life is beautiful.
But I can't do the following :
import { AppComponent } from '.'; // or './', or even './index'
The IDE (Visual Studio) actually resolves the import correctly (it compiles with no errors). I even get autocompletion from Intellisence...
But I get this error at runtime :
Error: Unexpected value 'undefined' imported by the module 'AppModule'
And I just don't know why.
Note : I don't have any error by importing from index.ts from subfolders (e.g. I can do import from './core' that also has an index).
Thank you in advance :)
.\app.component
.. – Hyperformangular cli
? – Hyperform../../viewees/shapes/
doesn't work withindex.ts
on that folder, but../../viewees/shapes/Rectangle
does work. Which typescript version are you using? – Expiable