javascript - Unable to export/import class from module/namespace in TypeScript -


i'm playing around typescript , export/import.

i want have file-structure in c#. want nest helper-class whic contains constant string-properties. file ~/scripts/helper/urlhelper.ts looks like:

module helper.urlhelper {     abstract class controller {         protected static readonly controllername: string;     }      export abstract class account extends controller {         static controllername: string = "account";          static readonly loginget: string = [account.controllername, "login"].join("/");         static readonly loginpost: string = [account.controllername, "login"].join("/");     } } 

my goal use values e.g. helper.urlhelper.account.loginpost. don't import/export work.

my last try add export * "./helper/urlhelper" , use import import {account} "../helper/urlhelper";

this leads error:

module '".../scripts/helper/urlhelper"' has no exported member 'account'

i tried here, nothing worked. doing wrong?

do not use keyword module, export members need import elsewhere:

// helper/urlhelper.ts abstract class controller {     protected static readonly controllername: string; }  export abstract class account extends controller {     static controllername: string = "account";      static readonly loginget: string = [account.controllername, "login"].join("/");     static readonly loginpost: string = [account.controllername, "login"].join("/"); } 

then, exported member account can imported:

// other-directory/other-file.ts import { account } "../helper/urlhelper" 

the documentation on modules here:

you use namespaces isn't es6 standard. if want namespaces, here documentation:

see also:


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -