Comparing version 1.0.2 to 1.0.3
@@ -63,2 +63,8 @@ import { InjectFlags, Injector } from './injector'; | ||
} | ||
if (notFoundValue !== THROW_IF_NOT_FOUND) { | ||
return notFoundValue; | ||
} | ||
if (flags === InjectFlags.Optional) { | ||
return null; | ||
} | ||
throw provideScopeError(normalizedProvider.scope); | ||
@@ -108,3 +114,3 @@ } | ||
if (this.parentInjector) { | ||
reflectiveValue = this.parentInjector.get(injectToken, tryValue, dep.optional ? InjectFlags.Optional : InjectFlags.Default); | ||
reflectiveValue = this.parentInjector.get(injectToken, tryValue); | ||
} | ||
@@ -111,0 +117,0 @@ else { |
@@ -121,3 +121,3 @@ import { InjectFlags } from './injector'; | ||
if (typeof metadata === 'undefined') { | ||
throw new Error(`class \`${stringify(construct)}\` is not injectable!`); | ||
throw new Error(`Class \`${stringify(construct)}\` is not injectable!`); | ||
} | ||
@@ -164,3 +164,3 @@ const deps = (metadata.paramTypes || []).map(i => [i]); | ||
if (typeof r.injectKey === 'undefined') { | ||
throw new Error(`the ${index} th dependent parameter type of \`${stringify(provide)}\` was not obtained, | ||
throw new Error(`The ${index} th dependent parameter type of \`${stringify(provide)}\` was not obtained, | ||
if the dependency is declared later, you can refer to it using \`constructor(@Inject(forwardRef(() => [Type|InjectionToken])) paramName: [Type]) {}\``); | ||
@@ -167,0 +167,0 @@ } |
@@ -11,3 +11,3 @@ import { stringify } from './stringify'; | ||
return function provideError(token) { | ||
const error = new Error(`can not found provide scope \`${stringify(token)}\`!`); | ||
const error = new Error(`Can not found provide scope \`${stringify(token)}\`!`); | ||
error.name = name; | ||
@@ -14,0 +14,0 @@ return error; |
@@ -111,2 +111,8 @@ var __extends = (this && this.__extends) || (function () { | ||
} | ||
if (notFoundValue !== null_injector_1.THROW_IF_NOT_FOUND) { | ||
return notFoundValue; | ||
} | ||
if (flags === injector_1.InjectFlags.Optional) { | ||
return null; | ||
} | ||
throw provideScopeError(normalizedProvider.scope); | ||
@@ -159,3 +165,3 @@ } | ||
if (_this.parentInjector) { | ||
reflectiveValue = _this.parentInjector.get(injectToken, tryValue, dep.optional ? injector_1.InjectFlags.Optional : injector_1.InjectFlags.Default); | ||
reflectiveValue = _this.parentInjector.get(injectToken, tryValue); | ||
} | ||
@@ -162,0 +168,0 @@ else { |
@@ -174,3 +174,3 @@ var __assign = (this && this.__assign) || function () { | ||
if (typeof metadata === 'undefined') { | ||
throw new Error("class `" + stringify_1.stringify(construct) + "` is not injectable!"); | ||
throw new Error("Class `" + stringify_1.stringify(construct) + "` is not injectable!"); | ||
} | ||
@@ -217,3 +217,3 @@ var deps = (metadata.paramTypes || []).map(function (i) { return [i]; }); | ||
if (typeof r.injectKey === 'undefined') { | ||
throw new Error("the " + index + " th dependent parameter type of `" + stringify_1.stringify(provide) + "` was not obtained,\nif the dependency is declared later, you can refer to it using `constructor(@Inject(forwardRef(() => [Type|InjectionToken])) paramName: [Type]) {}`"); | ||
throw new Error("The " + index + " th dependent parameter type of `" + stringify_1.stringify(provide) + "` was not obtained,\nif the dependency is declared later, you can refer to it using `constructor(@Inject(forwardRef(() => [Type|InjectionToken])) paramName: [Type]) {}`"); | ||
} | ||
@@ -220,0 +220,0 @@ return r; |
@@ -24,3 +24,3 @@ (function (factory) { | ||
return function provideError(token) { | ||
var error = new Error("can not found provide scope `" + stringify_1.stringify(token) + "`!"); | ||
var error = new Error("Can not found provide scope `" + stringify_1.stringify(token) + "`!"); | ||
error.name = name; | ||
@@ -27,0 +27,0 @@ return error; |
{ | ||
"name": "@tanbo/di", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A dependency injection Library", | ||
@@ -5,0 +5,0 @@ "main": "./bundles/umd/public-api.js", |
81801
2082