0

Look at the code in the TypeScript playground. I need comments to be placed in the result JS code to have an ability to determine browser is IE according to this question. cc_on is a IE conditional compilation directive.

TypeScript

window.IsBrowser = {
    IE: function() {
        return /*@cc_on!@*/false;
    }
};

Compiled JavaScript

window.IsBrowser = {
    IE: function () {
        return false;
    }
};
Community
  • 1
  • 1
Sergey Metlov
  • 25,747
  • 28
  • 93
  • 153

1 Answers1

2

If you use WebEssentials 2012, you have the option to retain comments. After installing the extension, in VS 2012, go to Tools > Options > Web Essentials > TypeScript > Keep comments and set that value to true.

Your sample works fine for me in VS2012 with WE:

window["IsBrowser"] = {  // I presume this came from a plugin or another script? Window doesn't have an 'IsBrowser' property.
    IE: function () {
        return /*@cc_on!@*/false;
    }
};

Compiles to:

window["IsBrowser"] = {
    IE: function () {
        return /*@cc_on!@*/ false;
    }
};

Update: Although I recommend WebEssentials for all kinds of other reasons, you can do this without - see @SteveFenton's useful comment below.

Jude Fisher
  • 11,138
  • 7
  • 48
  • 91