Angular 2 typescript import module

How can I import a TypeScript plug-in into an Angular 2 TypeScript file?

I will give an example:

Let's say I have to follow the TypeScript file (which was automatically generated by the TypeWriter extension):

module TypeWriter.Templates {

     export interface IAppConfiguration {

        Environment: Environment;
    }

    export class AppConfiguration  implements IAppConfiguration  {

        Environment: Environment;

        constructor() {         
          //nothing                   
        }
    }
}

An environment is an enumeration that is declared in another file like this (also automatically generated): Note that both external modules have the same module name.

module TypeWriter.Templates {

    export enum Environment {
        Dev = 1,
        QA = 2,
        Prod = 3,
    }     
}

And I have another TS Angular 2 service file:

import { Injectable } from '@angular/core';

@Injectable()
export class SomeService {    


}

How to import AppConfiguration into SomeService? Currently, when he tries to import it, it does not work, and the compiler says that Common.ts is not a module:

import { AppConfiguration } from "./models/Common";

, SomeService - : import... , AppConfiguration - TypeScript (TypeWriter.Templates), ...

P.S : TypeScript TypeWrite - ...

+4

Source: https://habr.com/ru/post/1679317/


All Articles