Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions __tests__/shim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,24 @@ describe('SHIM: VueTypes', () => {
expect((VueTypes as any).dateFn().isRequired.required).toBe(true)
})

it('should accept multiple types as array', () => {
VueTypes.extend([
{
name: 'type1',
type: String,
getter: true,
},
{
name: 'type2',
type: Number,
getter: true,
},
])

expect((VueTypes as any).type1.type).toBe(String)
expect((VueTypes as any).type2.type).toBe(Number)
})

it('should add a validate method to the prop', () => {
VueTypes.extend({
name: 'stringCustom',
Expand Down
4 changes: 4 additions & 0 deletions src/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ const BaseVueTypes = /*#__PURE__*/ (() =>
static objectOf = objectOf
static shape = shape
static extend<T = any>(props: any): T {
if (isArray(props)) {
props.forEach((p) => this.extend(p))
return this as any
}
const { name, validate, getter = false, type = null } = props
// If we are inheriting from a custom type, let's ignore the type property
const extType = isPlainObject(type) && type.type ? null : type
Expand Down