Separate ts file for imports

177 views Asked by At

I want to create a separate ts file (eg: imports.ts) which will consist all my imports syntax and whichever component file will need the import I just want to reference the imports file rather than writing the whole set of import again, please suggest me how can I attain this.

Example:

imports.ts should be something like

import {Component, View, bootstrap} from 'angular2/angular2'; 
import {foo} from 'fooMod';

and other ts like

 //here i need the help how can i import from imports.ts
@Component({
selector: 'display'
})
@View({
template: `
   <p>My name: {{ myName }}</p>
 `
 })
class DisplayComponent {
myName: string;

constructor() {
    this.myName = "Alice";
   }
}
1

There are 1 answers

0
TGH On

One way would be to create a wrapper object that imports and exposes other dependencies as properties. You can then import that single umbrella object to gain access to the other modules.