dependency-injection-cat
Version:
DI Cat is a truly clean DI-container, which allows you not to pollute your business logic with decorators from DI/IOC libraries!
61 lines (60 loc) • 2.42 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPropertyBeanInfo = void 0;
var ts = __importStar(require("typescript"));
var getScopeValue_1 = require("./getScopeValue");
var CompilationContext_1 = require("../../../compilation-context/CompilationContext");
function getPropertyBeanInfo(propertyDeclaration) {
var beanCall = propertyDeclaration.initializer;
if (beanCall.arguments.length === 0) {
CompilationContext_1.CompilationContext.reportError({
node: beanCall.expression,
message: 'You should pass at least 1 argument to the Bean call',
filePath: propertyDeclaration.getSourceFile().fileName,
relatedContextPath: propertyDeclaration.getSourceFile().fileName,
});
return {
scope: 'singleton',
};
}
var secondArg = beanCall.arguments[1];
if (secondArg === undefined) {
return {
scope: 'singleton',
};
}
if (!ts.isObjectLiteralExpression(secondArg)) {
CompilationContext_1.CompilationContext.reportError({
node: secondArg,
message: 'Argument in Bean should be object literal',
filePath: propertyDeclaration.getSourceFile().fileName,
relatedContextPath: propertyDeclaration.getSourceFile().fileName,
});
return {
scope: 'singleton',
};
}
return {
scope: (0, getScopeValue_1.getScopeValue)(secondArg),
};
}
exports.getPropertyBeanInfo = getPropertyBeanInfo;