What is the best way to import TypeScript external module to Angular 2 TypeScript file?
I'll give an example:
Say I have to following TypeScript file (which was auto-generated by TypeWriter extension):
module TypeWriter.Templates {
export interface IAppConfiguration {
Environment: Environment;
}
export class AppConfiguration implements IAppConfiguration {
Environment: Environment;
constructor() {
//nothing
}
}
}
Environment is enum which is declared in other file like this (Also auto-generate): Notice that both external module has the same module name.
module TypeWriter.Templates {
export enum Environment {
Dev = 1,
QA = 2,
Prod = 3,
}
}
And I have another Angular 2 service TS file:
import { Injectable } from '@angular/core';
@Injectable()
export class SomeService {
}
How can I import AppConfiguration to SomeService? Currently when tried to import it like this it doesn't work and the compiler says Common.ts is not a module:
import { AppConfiguration } from "./models/Common";
Basically I would like to be able to use SomeService without any need to write something like: import... In the same way that AppConfiguration now recognize Environment - because they sit in the same TypeScript module (TypeWriter.Templates) so no imports needed...
P.S I saw this related question: Importing TypeScript modules But in this way I'll have to add imports to my TypeWrite auto-generated files - which will be a mess...