Question

Update

You can read all the details below.. but basically, now matter what I do VS2012 Typescript is compiling and saving ANSI files...

I can manually resave the files as UTF-8 and everything works fine..

I am on Windows 8, and I have reproduced this issue on 5 different machines used by 5 different developers in 3 different cities...

The only commonality is Windows 8

I have a sample project that works great in IE but not at all in Chrome or FF. It looks like the files are being encoded improperly and IE is figuring it out but Chrome and FF aren't...

For example, here are the first few likes of a compiled JavaScript file

/// <reference path="../Framework/Core.ts" /> 
var MVVM; 
(function (MVVM) {
var Application = (function () {
    function Application() {
        this.core = undefined;
        this.templatePath = "Atlatl/Templates/";
        this.viewPath = "Atlatl/Views/";
        this.dependentScriptsPath = "Scripts/";
        this.viewModelsPath = "Atlatl/App/ViewModels/";
        this.frameworkPath = "Atlatl/Framework/";
        this.pages = {
        };

and here is what Chrome "thinks" its receiving from IIS (8 & 8 express) :

 爼晥牥湥散瀠瑡㵨⸢⼮牆浡睥牯⽫潃敲琮≳⼠ാ瘊牡䴠噖㭍਍昨湵瑣潩䴨噖⥍笠਍††慶⁲灁汰捩瑡潩‽昨湵瑣潩⤨笠

Update

And here are the headers from the chrome call for the file

-- Request --

Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:localhost:40665
If-Modified-Since:Wed, 03 Apr 2013 16:33:17 GMT
If-None-Match:"153551f28830ce1:0"
Referer:http://localhost:40665/
User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31

--Response--

Accept-Ranges:bytes
Date:Wed, 03 Apr 2013 17:06:28 GMT
ETag:"153551f28830ce1:0"
Server:Microsoft-IIS/8.0
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?QzpcUHJvamVjdHNcUmFuZG9tV29ya1xNdmNBcHBsaWNhdGlvbjEyXE12Y0FwcGxpY2F0aW9uMTJcQXRsYXRsXEFwcFxhcHAuanM=?=

nothing too funny in there...

I have tried all the following compilation methods with various failures, all along the same lines

1) Just using the TypeScript compiler in VS

2) Using Web Essentials

A) With and without UTF-8 BOM flags set to true

B) With and without recompiling on build

I can provide a sample project, or if you go through this tutorial you will see what I am talking about https://github.com/CatapultSystems/atlatl/wiki/Visual-studio-hello-world

I am totally stumped as to what could be causing this... and am all ears as to what's up..

Was it helpful?

Solution

I don't think it is anything related with the compilation or TypeScript.

The generated JavaScript files are OK without the BOM.

The response should contain Content-Length: XXXX and Content-Type: application/javascript - and yours does not. It seems a 304 Not Modified response instead than a 200 OK one.

Have you tried to force a refresh in Chrome using Ctrl+F5 ?

UPDATE

Re-saving in notepad the JavaScript file selecting UTF-8 just adds the BOM (assuming that the content of the JS file is 7 bit ASCII).

You should be able to produce the same effect setting Web Essentials to add the BOM, or adding a dummy string constant

var dummyChars = "Ù";

to your TypeScript file. After you do this the JavaScript file should be identical to the one generated saving from Notepad.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top