ts-simple-ast
Version:
TypeScript compiler wrapper for static analysis and code manipulation.
71 lines (70 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var utils_1 = require("../../../utils");
/**
* Result of an emit.
*/
var EmitResult = /** @class */ (function () {
/**
* @private
*/
function EmitResult(context, compilerObject) {
this._context = context;
this._compilerObject = compilerObject;
// memoize because diagnostics have dependencies that need to be memoized
this.getDiagnostics();
}
Object.defineProperty(EmitResult.prototype, "compilerObject", {
/**
* TypeScript compiler emit result.
*/
get: function () {
return this._compilerObject;
},
enumerable: true,
configurable: true
});
/**
* If the emit was skipped.
*/
EmitResult.prototype.getEmitSkipped = function () {
return this.compilerObject.emitSkipped;
};
/**
* Contains declaration emit diagnostics.
*
* This is the semantic, syntactic, global, options, and if enabled declaration diagnostics.
*/
EmitResult.prototype.getDiagnostics = function () {
var _this = this;
return this.compilerObject.diagnostics.map(function (d) { return _this._context.compilerFactory.getDiagnostic(d); });
};
tslib_1.__decorate([
utils_1.Memoize
], EmitResult.prototype, "getDiagnostics", null);
return EmitResult;
}());
exports.EmitResult = EmitResult;
/**
* Result of an emit to memory.
*/
var MemoryEmitResult = /** @class */ (function (_super) {
tslib_1.__extends(MemoryEmitResult, _super);
/**
* @private
*/
function MemoryEmitResult(context, compilerObject, _files) {
var _this = _super.call(this, context, compilerObject) || this;
_this._files = _files;
return _this;
}
/**
* Gets the files that were emitted to memory.
*/
MemoryEmitResult.prototype.getFiles = function () {
return this._files; // assert mutable array
};
return MemoryEmitResult;
}(EmitResult));
exports.MemoryEmitResult = MemoryEmitResult;