Skip to content

Commit 2872481

Browse files
committed
fix(shared): 当值存在的时候赋值
1 parent 23da726 commit 2872481

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/shared/src/construct.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Container } from './container'
2-
import { isBoolean, isUndef } from './type'
2+
import { isBoolean, isDef } from './type'
33

44
export const poolContainer = new Container<
55
Object,
@@ -11,7 +11,7 @@ export const construct = (target: Function, params: unknown[] = []) => {
1111
const instanceContainer = poolContainer.use(target.prototype)
1212
if (!isBoolean(instanceContainer)) {
1313
for (let [key, value] of instanceContainer.getPool().entries()) {
14-
if (isUndef(value)) {
14+
if (isDef(value)) {
1515
defineProperty(instance, key, value)
1616
} else {
1717
instanceContainer.on(key, (inject) => {

packages/shared/src/type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const isBoolean = (value: any): value is boolean =>
22
typeof value === 'boolean'
33

4-
export const isUndef = (value: any): value is undefined =>
5-
typeof value === 'undefined'
4+
export const isDef = (value: any): value is undefined =>
5+
typeof value !== 'undefined'

0 commit comments

Comments
 (0)