File tree Expand file tree Collapse file tree 3 files changed +29
-10
lines changed Expand file tree Collapse file tree 3 files changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export {
1515 ComponentOptions ,
1616 FunctionalComponentOptions ,
1717 RenderContext ,
18+ PropType ,
1819 PropOptions ,
1920 ComputedOptions ,
2021 WatchHandler ,
Original file line number Diff line number Diff line change @@ -142,12 +142,14 @@ export interface RenderContext<Props=DefaultProps> {
142142 injections : any
143143}
144144
145- export type Prop < T > = { ( ) : T } | { new ( ...args : any [ ] ) : T & object }
145+ export type Prop < T > = { ( ) : T } | { new ( ...args : any [ ] ) : T & object }
146146
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 > ;
148150
149151export interface PropOptions < T = any > {
150- type ?: Prop < T > | Prop < T > [ ] ;
152+ type ?: PropType < T > ;
151153 required ?: boolean ;
152154 default ?: T | null | undefined | ( ( ) => T | null | undefined ) ;
153155 validator ?( value : T ) : boolean ;
Original file line number Diff line number Diff line change 1- import Vue , { VNode } from "../index" ;
1+ import Vue , { PropType , VNode } from "../index" ;
22import { ComponentOptions , Component } from "../index" ;
33import { CreateElement } from "../vue" ;
44
@@ -59,20 +59,36 @@ class Cat {
5959 private u = 1
6060}
6161
62+ interface IUser {
63+ foo : string ,
64+ bar : number
65+ }
66+
67+ interface ICat {
68+ foo : any ,
69+ bar : object
70+ }
71+
6272Vue . component ( 'union-prop' , {
6373 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 ] ,
6578 object : [ Cat , User ] ,
79+ primitive : [ String , Number ] ,
6680 regex : RegExp ,
67- mixed : [ RegExp , Array ] ,
68- union : [ User , Number ] as { new ( ) : User | Number } [ ] // requires annotation
81+ union : [ User , Number ] as PropType < User | number >
6982 } ,
7083 data ( ) {
71- this . primitive ;
84+ this . cat ;
85+ this . complexUnion ;
86+ this . kittyUser ;
87+ this . mixed ;
7288 this . object ;
73- this . union ;
89+ this . primitive ;
7490 this . regex . compile ;
75- this . mixed ;
91+ this . union ;
7692 return {
7793 fixedSize : this . union ,
7894 }
You can’t perform that action at this time.
0 commit comments