@baizey/dependency-injection
Version:
A simple typescript dependency injection
49 lines (48 loc) • 2.15 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SingletonScopedDependencyError = void 0;
var types_1 = require("./types");
var SingletonScopedDependencyError = /** @class */ (function (_super) {
__extends(SingletonScopedDependencyError, _super);
function SingletonScopedDependencyError(lifetime, cause) {
var _this = _super.call(this, "Singleton '".concat(lifetime.toString(), "' depends on scoped '").concat(cause.toString(), "', it is not allowed to as it would lock the scoped service into a singleton lifetime")) || this;
Object.defineProperty(_this, "lifetime", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(_this, "cause", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(_this, "type", {
enumerable: true,
configurable: true,
writable: true,
value: types_1.DependencyErrorType.SingletonScoped
});
_this.lifetime = lifetime.toString();
_this.cause = cause.toString();
return _this;
}
return SingletonScopedDependencyError;
}(Error));
exports.SingletonScopedDependencyError = SingletonScopedDependencyError;