Using external modules in TypeScript -


lets have following 2 external modules in typescript:

export module my.services.common  {     export class helper      {        //...     } } 

and

export module my.services  {     export class connection     {         //...     }     } 

now in app.ts use both connection , helper classes. want achieve similar following code in c#:

using my.services; using my.services.common; 

or @ least just

using my.services; 

but looks cant work @ same time both helper , connection. if write:

import {my} './services/common/helper'; import {my} './services/connection; 

leads error "duplicate identifier 'my'". logical though. question how can consume different classes same (or nested) modules?

my personal view on break away see in c# or java (which maps more closely internal modules) , treat more external modules using...

step 1. ditch module keyword. file module already.

step 2. provide non-dotted alias when import.

step 3. can import everything, '*', or specific classes when import.

./services/common.ts

export class helper  {    //... } 

./services.ts

export class connection {     //... } 

./app.ts

import * services './services' import { connection } './services/common'  var x = new services.helper();  var y = new connection(); 

you can import multiple members module too:

import { connection, example } './services/common'  var y = new connection();  var z = new example(); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -