I've created a new .ts file in a webproject using VS2015. In the properties for the project under TypeScript Build I've checked Module System = AMD.
Then when trying to write a external module i get the following error.
Cannot compile modules unless the '--module' flag is provided.
Where do I provide the moduel flag?
It seems to be a bug with VS2015 RTM. The project TypeScript settings are saved incorrectly to the .csproj file, so the TypeScript compiler isn't reading them.
To fix:
<TypeScriptModuleKind>
, and then locate the parent element, which should be called <PropertyGroup>
.Any CPU
" in the Condition
attribute value, change it to "AnyCPU
" -- i.e. remove the space.Note that until this bug is fixed, you'll need to edit the .csproj file to modify TypeScript settings. If you try to make the change from the project settings area, it will just generate new settings in the project file with the wrong condition value again.
Also, you may be reading about using a tsconfig.json file instead for providing the settings in VS2015. However, it seems that this capability is currently only implemented for the Website project type and not for Web Application projects.
I couldn't make it work. Whatever I change in typescript section - it's ignored on build.
If I set verbosity to Detailed in Tools->Options->Build and run I can see that all my settings are ignored, including -module
flag.
Just as workaround. Create a tsconfig.json file in root directory. And add in pre-build events "tsc" command. In this case it worked just fine.
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true
}
}
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