'export import' issues

Topics: General
Apr 6, 2014 at 5:30 PM
Edited Apr 7, 2014 at 10:47 AM
I've just started experimenting with converting a project to use external AMD modules, and am facing an issue with a particular part. I regularly have a group of files that naturally belong together, for example:

at /geom/Point.ts
export class Point { public x: number = 0; public y: number = 0; public static zero: Point = new Point() }
at /geom/Rect.ts
export class Rect { public p1: Point; public p2: Point }
If a code file wants to use 'Rect', it always wants to use 'Point' too. Rather than reference both I just wrote a file like so:

at /geom/geom.ts
/// <reference path="Point.ts" />
/// <reference path="Rect.ts" />
i.e. a file that is nothing but a list of references. To emulate this with AMD, I tried the following:

at /geom/geom.ts
export import Point = require("./Point.ts");
export import Rect = require("./Rect.ts");
And then if a file needs to use the geom namespace:
import geom = require("geom/geom");
var rect = new geom.Rect { p1: new geom.Point(0,0), p2: new geom.Point(1,1) };
This seems to work, but there are issues with the IDE:

1 - The construction of the geom.Point instances shows as an error on the IDE ("Invalid 'new' expression"). Oddly, the construction of the geom.Rect does not.

2 - I can't see the static properties on geom.Point. If I typed 'geom.Point' then VS shows my the 'x' and 'y' properties (i.e. the instance members, not the static members.

In spite of these issues, the code builds and runs just fine!

Are there any problems with doing what I'm doing?

EDIT: I've filed an issue for this problem too : https://typescript.codeplex.com/workitem/2397