The internal module does not work if there is an import statement in front of it

I am trying to move from using external ( export ) modules to using internal modules. But I get an error when I delete the "export".

I have a file like this:

box.ts:

 import {computedFrom} from 'aurelia-framework'; module Entities { export class Box { .. Stuff } 

I am using this in another file.

service actions.ts:

 /// <reference path="../entities/box.ts" /> .... var box = new Entities.Box(); 

This gives me the following error:

The 'Box' property does not exist on 'typeof (Entities)'

But if I output import {computedFrom} from 'aurelia-framework'; then the error will disappear (it works fine).

I tried moving import {computedFrom} from 'aurelia-framework'; into the module. When I do this, the error is gone, but I get a new one:

Importing declarations in the namespace cannot reference the module.

What can I do to use the computedFrom module in my class? (Should it be an external module to work?)

0
javascript import module typescript
Dec 10 '15 at 17:14
source share
1 answer

In general, it is better to avoid mixing internal and external modules .

External modules (or modules, as they are now known) are actually quite elegant, and you can organize your code well without internal modules (or namespaces, as they are now known).

box.ts:

 import {computedFrom} from 'aurelia-framework'; export class Box { .. Stuff } 

service actions.ts:

 import {Box} from './box' var box = new Box(); 
0
Dec 10 '15 at 17:20
source share



All Articles