Is there an option to tell the TypeScript compiler to obey certain "rules" such as naming anonymous functions, always add the "use strict" declaration, and to always use braces?
For example, whenever you use the "extends" keyword for class inheritance, for instance, TypeScript will output this function:
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
My team's JSHint rules require "curly" braces around conditionals, and require named anonymous functions (technically "named functional expressions"). Basically I'd like TypeScript's transpiler to produce better quality JavaScript code, in terms of style as opposed to efficiency (although well-performing code is also important, of course).
We can use tslint to lint our TypeScript, but I'd like to also ensure that the generated code also meets certain quality standards.
"use strict";to the top of each file in a build script (and I can understand the need for that when trying to get the code to run in certain environments), but the other changes you are talking about require either parsing the javascript code and fixing the linting errors, or changing the compiler source (all this would slow down the build and be quite a lot of work to maintain); however, to partly echo what mk said in their answer, I would suggest if you're going to write code in TypeScript that you focus on the TypeScript and use tslint.--noEmitHelpersand provide your own well-formatted__extendsfunction somewhere at global scope.