I want to create local modules in my TypeScript (with Angular 2) app and then simple reference to any file with importing module like myApp/components
, myApp/pipes
etc., not using relative path (../../../MyComponent) as I have to do now.
For instance, Angular 2 can be used like this. (And I haven't found how they make it)
import {Component} from 'angular2/core';
How can I achieve this behavior?
I did some files like components.ts
, templates.ts
etc. where I export files from current section:
export * from './menu/item';
export * from './menu/logo';
export * from './article/article';
export * from './article/sidebar';
... and then I have one main file myApp.ts
where I declare modules like so:
declare module 'myapp/components' {
export * from './application/components';
}
declare module 'myapp/templates' {
export * from './application/templates';
}
But this file doesn't generate anything so TS build tells me errors like ...file_path...(4,9): error TS2305: Module ''myapp/components'' has no exported member 'AlfaBeta'.
Btw. my tsconfig.json
looks like this:
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}