javascript - Referencing a file (module) in Typescript using AMD -
i new typescript , module handling. in project coding in typescript developing browser library. therefore using amd. following tsconfig.json
file.
{ "compileroptions": { "target": "es5", "outdir": "out", "module": "amd" }, "files": [ "src/main.ts", "src/communication.ts", ... ] }
file communication.ts
is:
export module myproj.dataexchange { export interface communication { connect(uri: string): void; close(): void; status: int; } }
referencing components other files
i want use communication
in main.ts
:
import communication = require('./communication'); export module myproj { export class communicator implements communication.myproj.dataexchange.communication { ... } }
i avoid using whole signature communication.myproj.dataexchange.communication
. tried like:
import communication = require('./communication').myproj.dataexchange;
but did not work.
my questions
i have feeling doing wrong in here. here questions:
- am doing things way supposed done?
- how avoid using whole name imported component?
- in case might tell me not use
module
, need separate components namespaces. how correctly set namespaces in case doing wrong?
in typescript 1.4 have been introduced type aliases.
your code might adapted use aliases this:
import communication = require('./communication') type communication = communication.myproj.dataexchange.communication; export module myproj { export class communicator implements communication { ... } }
Comments
Post a Comment