0
votes

Has anybody had any luck with the new modules support in VS2015 and Typescript 1.5? I wrote up a quick example that has one module "Main.ts" importing "Lib" and just calling two test functions.

When I compile this in VS2015 it gives me a compiler error on Lib.ts that I need to specify --module flag.

Lib.ts

export function Func1() { 
    console.log("Func1 called"); 
}

export function Func2() {
    console.log("Func2 called");
}

Main.ts

import * as TheLib from "Lib";

module Main { 
    export function SomeWorkHere() { 
        console.log("SomeWorkHere called");
        TheLib.Func1();
        TheLib.Func2();
    }
}

I have verified that my module system is "on". (I tried AMD, CommonJS, UMD) all with same compiler results.

SO: I tried running the tsc (Typescript Compiler) from the command line and it compiles fine!

Has anybody experienced this? Any ideas on how to bend the IDE to my will?

1
Here's Lib.ts: export function Func1() { console.log("Func1 called"); } export function Func2() { console.log("Func2 called"); } and Main.ts: import * as TheLib from "Lib"; module Main { export function SomeWorkHere() { console.log("SomeWorkHere called"); TheLib.Func1(); TheLib.Func2(); } } - James Scott
you can edit your post instead of just adding a comment - Jason Kleban

1 Answers

0
votes

When you adjust your project settings, you need to do it for each configuration you are running. Sometimes you'll change it in "Debug" and when you switch to "Release" it all stops working, because it hasn't got the setting.

Configuration Modes

Additionally, if you have been following TypeScript for a while, you may find that your PATH variable has a path to an old version. Make sure you only have one path to the TypeScript compiler and make sure that it is the latest one.

Finally, if your project has been around a while, make sure the TypeScript tools version is correct. You'll find it in the project file:

<TypeScriptToolsVersion>1.5</TypeScriptToolsVersion>

Other than these items - I dropped your code into a new project and it compiled fine.