Skip to content

Commit a3fb74a

Browse files
committed
Merge branch 'release/1.3.1'
2 parents f8e9f42 + b8e5cf7 commit a3fb74a

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-types",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Prop types utility for Vue",
55
"author": "Marco Solazzi",
66
"license": "MIT",

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export {
1212
VueTypeDef,
1313
VueTypeInstanceOf,
1414
VueTypeShape,
15+
VueTypeLooseShape,
1516
VueTypeArrayOf,
1617
ValidatorFunction,
1718
VueTypeCustom,

types/test/index.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ const shapeType = VueTypes.shape({
5757
name: String,
5858
surname: { type: String, default: 'Doe' },
5959
age: VueTypes.number,
60-
}).def({ name: 2 }).loose.isRequired;
60+
}).def({ name: 2 }).isRequired; // I guess this is just checkable at runtime
61+
62+
const shapeTypeLoose = VueTypes.shape({
63+
name: String,
64+
surname: { type: String, default: 'Doe' },
65+
age: VueTypes.number,
66+
}).loose.def({ nationality: 'unknown' }).isRequired;
6167

6268
shapeType.type = Object;
6369

@@ -81,7 +87,8 @@ const BaseComponent = Vue.extend({
8187
fieldWithText: VueTypes.oneOfType([String, VueTypes.string]),
8288
friendsId: VueTypes.arrayOf(VueTypes.number).isRequired,
8389
simpleObj: ObjectOfType,
84-
meta: shapeType
90+
meta: shapeType,
91+
extendedMeta: shapeTypeLoose
8592
}
8693
});
8794

@@ -101,7 +108,8 @@ const BaseComponent = Vue.extend({
101108
fieldWithText: VueTypes.oneOfType([String, VueTypes.string]),
102109
friendsId: VueTypes.arrayOf(VueTypes.number).isRequired,
103110
simpleObj: ObjectOfType,
104-
meta: shapeType
111+
meta: shapeType,
112+
extendedMeta: shapeTypeLoose
105113
}
106114
})
107115
class ClassComponent extends Vue {

types/vue-types.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ export interface VueTypeInstanceOf<T extends Constructor> extends VueTypeDef<Ins
1818
}
1919

2020
export interface VueTypeShape<T> extends VueTypeDef<T> {
21-
_vueTypes_isLoose?: boolean;
2221
readonly def: <P extends { [K in keyof T]?: any }>(def: P) => this & { default: P };
23-
readonly loose: this & { _vueTypes_isLoose: true };
22+
readonly loose: VueTypeLooseShape<T>;
23+
}
24+
25+
export interface VueTypeLooseShape<T> extends VueTypeShape<T> {
26+
readonly _vueTypes_isLoose: true;
27+
readonly def: <D extends { [K in keyof T]?: any } & { [key: string]: any }>(def: D) => this & { default: D };
2428
}
2529

2630
export interface VueTypeArrayOf<T> extends VueTypeDef<T[]> {

umd/vue-types.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

umd/vue-types.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)