This project is read-only.

TypeScript api with export assignment and export import

Topics: General
May 31, 2014 at 1:04 PM
I'm the author of gulp-type, a gulp plugin which compiles TypeScript with the TypeScript api. I had a problem with the following code:

Imagine a file class.ts which has an export assignment, that exports a class.
exportimport.ts exports that class: export import MyClass = require('./class');
main.ts imports exportimport.ts and creates a new instance of it:
import exportimport = require('./exportimport');
var test = new exportimport.MyClass();
Now the strange part:
The Compiler generates no error if the files are added to the Compiler in this order: class.ts, exportimport.ts, main.ts.
But if the files are added in this order: main.ts, exportimport.ts, class.ts, you get the error error TS2083: Invalid 'new' expression.

Is this by design? Should the files by added to the compiler in the order they reference each other? Or is this a bug?

As far as I know, other things (like export class ...) don't fail if you use another order.
May 31, 2014 at 1:45 PM
And even stranger, it works (in the order main, exportimport, class) with this main.ts:
import exportimport = require('./exportimport');
var test = new exportimport.MyClass();