12

I'm very new to typescript and am trying it out in the latest Visual Studio 2015 RC.

At the moment it compiles the typescript file automatically and creates the underlying js file (nicely underneath the .ts file when you expand it) when I save the ts file. However, there is no sourcemap file, so I never hit any breakpoints in the typescript in visual studio when debugging (regardless of using IE or Chrome canary).

Is there a way to enable it so it will generate the sourcemap files on save? From searching around it seems a lot of the compiler options that used to be in web essentials that have either moved or are not available (yet?):

Screenshot of old options-dialog

3 Answers 3

16

I found that by unloading the project and editing the 'xproj' file, if I add the following xml under the project node (before the property group containing 'VSToolsPath'):

<PropertyGroup>
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptCompileOnSaveEnabled>true</TypeScriptCompileOnSaveEnabled>
    <TypeScriptNoImplicitAny>false</TypeScriptNoImplicitAny>
    <TypeScriptModuleKind>AMD</TypeScriptModuleKind>
    <TypeScriptRemoveComments>false</TypeScriptRemoveComments>
    <TypeScriptOutFile></TypeScriptOutFile>
    <TypeScriptOutDir></TypeScriptOutDir>
    <TypeScriptGeneratesDeclarations>false</TypeScriptGeneratesDeclarations>
    <TypeScriptSourceMap>true</TypeScriptSourceMap>
    <TypeScriptMapRoot></TypeScriptMapRoot>
    <TypeScriptSourceRoot></TypeScriptSourceRoot>
    <TypeScriptNoEmitOnError>true</TypeScriptNoEmitOnError>
</PropertyGroup>

This fixed the issue and the .map files were generated on save (neatly under the js files). This enables me to hit my typescript breakpoints in Visual Studio (only with IE unfortunately).

Another beneficial side effect is that I can now export modules (because of the 'TypeScriptModuleKind' => AMD setting).

Sign up to request clarification or add additional context in comments.

4 Comments

You've done the correct thing. There is a UI for this under your project properties on the TypeScript Build tab. If you're using a projectless project type (like a web project), the default settings are in the TypeScript language options in the Visual Studio settings.
I couldn't see anything on the project properties (very sparse options in .NET5 web project currently) or visual studio options. I don't know if it's just because its release candidate or my install is iffy.
I can't see any of those options either developing an ASP.NET 5 app in Visual Studio 2015 RC. Thanks for the workaround with xproj - saved my day! :)
Please specify where the file is located
6

I've found an alternative if you go to add a new file to your project, there is a typescript configuration file option. So if you add a 'tsconfig.json' you get the same settings:

{
  "compilerOptions": {
    "module": "amd",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5"
  }
}

I guess this is better as it would potentially allow multiple configurations for different typescript apps in different folders. For my project I've just placed it in the root to apply globally.

Comments

0

I found another solution for .NET 4x projects within https://github.com/Microsoft/TypeScript/issues/5001:

Toggling some random setting on the TypeScript Build tab (with "Generate source maps" enabled) in the project properties added new TypeScript configuration lines to the project file, (finally) resulting in the Source Maps generated both upon save and (project) build.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.