diff --git a/__tests__/shim.test.ts b/__tests__/shim.test.ts index aee4db6e..c6ba4903 100644 --- a/__tests__/shim.test.ts +++ b/__tests__/shim.test.ts @@ -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', diff --git a/src/shim.ts b/src/shim.ts index c8084e22..0fea9f8d 100644 --- a/src/shim.ts +++ b/src/shim.ts @@ -159,6 +159,10 @@ const BaseVueTypes = /*#__PURE__*/ (() => static objectOf = objectOf static shape = shape static extend(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