+29
-10
lines changedFilter options
+29
-10
lines changed Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ export {
15
15
ComponentOptions,
16
16
FunctionalComponentOptions,
17
17
RenderContext,
18
+
PropType,
18
19
PropOptions,
19
20
ComputedOptions,
20
21
WatchHandler,
Original file line number Diff line number Diff line change
@@ -142,12 +142,14 @@ export interface RenderContext<Props=DefaultProps> {
142
142
injections: any
143
143
}
144
144
145
-
export type Prop<T> = { (): T } | { new (...args: any[]): T & object }
145
+
export type Prop<T> = { (): T } | { new(...args: any[]): T & object }
146
146
147
-
export type PropValidator<T> = PropOptions<T> | Prop<T> | Prop<T>[];
147
+
export type PropType<T> = Prop<T> | Prop<T>[];
148
+
149
+
export type PropValidator<T> = PropOptions<T> | PropType<T>;
148
150
149
151
export interface PropOptions<T=any> {
150
-
type?: Prop<T> | Prop<T>[];
152
+
type?: PropType<T>;
151
153
required?: boolean;
152
154
default?: T | null | undefined | (() => T | null | undefined);
153
155
validator?(value: T): boolean;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1
-
import Vue, { VNode } from "../index";
1
+
import Vue, { PropType, VNode } from "../index";
2
2
import { ComponentOptions, Component } from "../index";
3
3
import { CreateElement } from "../vue";
4
4
@@ -59,20 +59,36 @@ class Cat {
59
59
private u = 1
60
60
}
61
61
62
+
interface IUser {
63
+
foo: string,
64
+
bar: number
65
+
}
66
+
67
+
interface ICat {
68
+
foo: any,
69
+
bar: object
70
+
}
71
+
62
72
Vue.component('union-prop', {
63
73
props: {
64
-
primitive: [String, Number],
74
+
cat: Object as PropType<ICat>,
75
+
complexUnion: { type: [User, Number] as PropType<User | number> },
76
+
kittyUser: Object as PropType<ICat & IUser>,
77
+
mixed: [RegExp, Array],
65
78
object: [Cat, User],
79
+
primitive: [String, Number],
66
80
regex: RegExp,
67
-
mixed: [RegExp, Array],
68
-
union: [User, Number] as {new(): User | Number}[] // requires annotation
81
+
union: [User, Number] as PropType<User | number>
69
82
},
70
83
data() {
71
-
this.primitive;
84
+
this.cat;
85
+
this.complexUnion;
86
+
this.kittyUser;
87
+
this.mixed;
72
88
this.object;
73
-
this.union;
89
+
this.primitive;
74
90
this.regex.compile;
75
-
this.mixed;
91
+
this.union;
76
92
return {
77
93
fixedSize: this.union,
78
94
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4