webpack-typescript
Version:
Lightweight, cleanly designed TypeScript Loader for webpack.
32 lines (31 loc) • 1.24 kB
JavaScript
var ts = require('typescript');
var Diagnostics = (function () {
function Diagnostics() {
this.diagnostics = [];
}
Object.defineProperty(Diagnostics.prototype, "isEmpty", {
get: function () {
return this.diagnostics.length === 0;
},
enumerable: true,
configurable: true
});
Diagnostics.prototype.add = function (diagnostics) {
this.diagnostics = this.diagnostics.concat(diagnostics);
};
Diagnostics.prototype.toString = function () {
var text = '';
this.diagnostics.forEach(function (diagnostic) {
if (diagnostic.file) {
var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
text += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): ";
}
var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase();
text += category + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') + "\n";
});
return text;
};
return Diagnostics;
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Diagnostics;