Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript generated JS files encoding

I am using VS2015 and latest TypeScript (1.6.3). The generated JavaScript and map files are generated in Windows-1252 encoding. The source TypeScript files are UTF-8 with BOM. I do need the generated files to be UTF-8 with BOM as well in order to pass Windows Store certification.

Once I manually fix encoding of the generated files it's fine. But then I must include the generated files in source control and fix any newly added files.

There doesn't seem to be any settings to change the encoding. Is this a bug in the compiler?

The project type is jsproj, which doesn't seem to support tsconfig.json according to https://github.com/Microsoft/TypeScript/issues/3124

like image 351
David Bohunek Avatar asked Nov 15 '15 17:11

David Bohunek


1 Answers

Once I manually fix encoding of the generated files it's fine. But then I must include the generated files in source control and fix any newly added files.

Use the emitBOM and charset options in tsconfig.json:

{
    "compileOnSave": true,
    "compilerOptions": {

        //... other stuff

        "emitBOM": true,
        "charset": "utf8"
    },
    // ...
}

See schema : http://json.schemastore.org/tsconfig

like image 82
basarat Avatar answered Oct 09 '22 13:10

basarat