I'm using Visual Studio 2013 Update 3, and have the latest version of WebEssentials installed. Under my project settings, under the Typescript Build tab, I've set the Module system type to AMD. I have a Typescript file with the following simple code:
export class Test {
}
When I try to build, however, I get the following build error (which also shows up as a red squiggly in my editor): Cannot compile external modules unless the '--module' flag is provided.
I've been searching for an answer to this, but it seems like everything online is for pre 1.0 versions of Typescript, and don't seem to apply to my needs. Has anyone seen this behavior before, and if so, how did you resolve it?
Thanks in advance for any help! :)
Make sure that the file is included in visual studio as <TypeScriptCompile
Also make sure your settings are for both Debug
and Release
.
The module flag needed refers to what module loader that should be used in order to compile your code. As you might or might not know, there is AMD
and commonjs
style modules. The file you specified is a module, and in order to refer to it in another TypeScript file, you should define the module loader. This is because TypeScript compiles to JavaScript.
This means you have two options for the module flag:
I suggest you look them up if you don't know anything about them. If you go to TypeScript Playground, http://www.typescriptlang.org/Playground#src=export%20class%20Test%20%7B%0D%0A%7D
You'll see that this does compile. Playground takes amd
as module flag to compile.
What you want to choose thus depends on whether you are developing for the browser or in node.js.
Hope that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With