Skip to content

Commit 5defc58

Browse files
authored
Merge pull request #162 from iamricogo/main
fix: customType can not to be get multiple times because of redefine…
2 parents a313531 + 923da63 commit 5defc58

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

__tests__/shim.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,17 @@ describe('SHIM: VueTypes', () => {
639639
})
640640
expect((VueTypes as any).customTypeChild.type).toBe(null)
641641
})
642+
643+
it('should be able to be get multiple times (eg:to avoid redefined property)', () => {
644+
VueTypes.extend({
645+
name: 'booleanCustom',
646+
getter: true,
647+
type: Boolean,
648+
default: undefined,
649+
})
650+
expect((VueTypes as any).booleanCustom.type).toBe(Boolean)
651+
expect((VueTypes as any).booleanCustom.type).toBe(Boolean)
652+
})
642653
})
643654
})
644655

src/shim.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function createValidator(
9898
const prop = getter ? 'get' : 'value'
9999
const descr = {
100100
[prop]: () =>
101-
type(name, props, validable).def(
101+
type(name, Object.assign({}, props), validable).def(
102102
getter ? root.defaults[name] : undefined,
103103
),
104104
}

0 commit comments

Comments
 (0)