Skip to content

Commit

Permalink
fix: getMember 属性值为 Falsy 时返回 defaultValue
Browse files Browse the repository at this point in the history
  • Loading branch information
shirookie authored and harttle committed Apr 6, 2021
1 parent 42178af commit 609401f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export function isValidIdentifier (str: string) {
export function getMember<T> (clazz: Function, property: string, defaultValue: T): T
export function getMember<T> (clazz: Function, property: string): T | undefined
export function getMember<T> (clazz: Function, property: string, defaultValue?: T): T | undefined {
if (clazz[property]) return clazz[property]
if (clazz.prototype && clazz.prototype[property]) {
if (clazz[property] !== undefined) return clazz[property]
if (clazz.prototype && clazz.prototype[property] !== undefined) {
return clazz.prototype[property]
}
return defaultValue
Expand Down

0 comments on commit 609401f

Please sign in to comment.