@@ -134,6 +134,10 @@ export function generate(node: t.Node | t.PropTypeNode[], options: GenerateOptio
134
134
return `${ importedName } .${ node . elementType } ` ;
135
135
}
136
136
137
+ if ( t . isInstanceOfNode ( node ) ) {
138
+ return `${ importedName } .instanceOf(${ node . instance } )` ;
139
+ }
140
+
137
141
if ( t . isArrayNode ( node ) ) {
138
142
if ( t . isAnyNode ( node . arrayType ) ) {
139
143
return `${ importedName } .array` ;
@@ -145,10 +149,14 @@ export function generate(node: t.Node | t.PropTypeNode[], options: GenerateOptio
145
149
if ( t . isUnionNode ( node ) ) {
146
150
let [ literals , rest ] = _ . partition ( node . types , t . isLiteralNode ) ;
147
151
literals = _ . uniqBy ( literals , x => x . value ) ;
148
- rest = _ . uniqBy ( rest , x => x . type ) ;
152
+ rest = _ . uniqBy ( rest , x => ( t . isInstanceOfNode ( x ) ? ` ${ x . type } . ${ x . instance } ` : x . type ) ) ;
149
153
150
154
literals = literals . sort ( ( a , b ) => a . value . localeCompare ( b . value ) ) ;
151
- rest = rest . sort ( ( a , b ) => a . type . localeCompare ( b . type ) ) ;
155
+ rest = rest . sort ( ( a , b ) =>
156
+ ( t . isInstanceOfNode ( a ) ? `${ a . type } .${ a . instance } ` : a . type ) . localeCompare (
157
+ t . isInstanceOfNode ( b ) ? `${ b . type } .${ b . instance } ` : b . type ,
158
+ ) ,
159
+ ) ;
152
160
153
161
if ( literals . find ( x => x . value === 'true' ) && literals . find ( x => x . value === 'false' ) ) {
154
162
rest . push ( t . booleanNode ( ) ) ;
0 commit comments