File tree Expand file tree Collapse file tree 3 files changed +98
-8
lines changed Expand file tree Collapse file tree 3 files changed +98
-8
lines changed Original file line number Diff line number Diff line change @@ -2071,6 +2071,87 @@ Object {
2071
2071
}
2072
2072
` ;
2073
2073
2074
+ exports [` nested intersection type with default props 1` ] = `
2075
+ Object {
2076
+ " classes" : Array [
2077
+ Object {
2078
+ " kind" : " intersection" ,
2079
+ " name" : Object {
2080
+ " kind" : " id" ,
2081
+ " name" : " Component" ,
2082
+ " type" : null ,
2083
+ },
2084
+ " types" : Array [
2085
+ Object {
2086
+ " kind" : " generic" ,
2087
+ " value" : Object {
2088
+ " kind" : " intersection" ,
2089
+ " types" : Array [
2090
+ Object {
2091
+ " kind" : " generic" ,
2092
+ " value" : Object {
2093
+ " kind" : " object" ,
2094
+ " members" : Array [
2095
+ Object {
2096
+ " default" : Object {
2097
+ " kind" : " string" ,
2098
+ " value" : " baz" ,
2099
+ },
2100
+ " key" : Object {
2101
+ " kind" : " id" ,
2102
+ " name" : " bar" ,
2103
+ },
2104
+ " kind" : " property" ,
2105
+ " optional" : false ,
2106
+ " value" : Object {
2107
+ " kind" : " string" ,
2108
+ },
2109
+ },
2110
+ ],
2111
+ },
2112
+ },
2113
+ Object {
2114
+ " kind" : " object" ,
2115
+ " members" : Array [
2116
+ Object {
2117
+ " key" : Object {
2118
+ " kind" : " id" ,
2119
+ " name" : " foo" ,
2120
+ },
2121
+ " kind" : " property" ,
2122
+ " optional" : false ,
2123
+ " value" : Object {
2124
+ " kind" : " string" ,
2125
+ },
2126
+ },
2127
+ ],
2128
+ },
2129
+ ],
2130
+ },
2131
+ },
2132
+ Object {
2133
+ " kind" : " object" ,
2134
+ " members" : Array [
2135
+ Object {
2136
+ " key" : Object {
2137
+ " kind" : " id" ,
2138
+ " name" : " isDefaultChecked" ,
2139
+ },
2140
+ " kind" : " property" ,
2141
+ " optional" : false ,
2142
+ " value" : Object {
2143
+ " kind" : " boolean" ,
2144
+ },
2145
+ },
2146
+ ],
2147
+ },
2148
+ ],
2149
+ },
2150
+ ],
2151
+ " kind" : " program" ,
2152
+ }
2153
+ ` ;
2154
+
2074
2155
exports [` new expression 1` ] = `
2075
2156
Object {
2076
2157
" classes" : Array [
Original file line number Diff line number Diff line change @@ -58,16 +58,9 @@ const resolveFromGeneric = type => {
58
58
59
59
const getProp = ( props , property ) => {
60
60
let prop ;
61
-
62
61
if ( props . kind === 'intersection' ) {
63
62
props . types . forEach ( pr => {
64
- if ( pr . kind === 'generic' ) {
65
- if ( pr . value . kind === 'object' ) {
66
- prop = getPropFromObject ( pr . value , property ) || prop ;
67
- }
68
- } else if ( pr . kind === 'object' ) {
69
- prop = getPropFromObject ( pr , property ) || prop ;
70
- }
63
+ prop = getProp ( resolveFromGeneric ( pr ) , property ) || prop ;
71
64
} ) ;
72
65
} else if ( props . kind === 'object' ) {
73
66
prop = getPropFromObject ( props , property ) ;
Original file line number Diff line number Diff line change @@ -218,6 +218,22 @@ const TESTS = [
218
218
}
219
219
`
220
220
} ,
221
+ {
222
+ name : 'nested intersection type with default props' ,
223
+ typeSystem : 'flow' ,
224
+ code : `
225
+ type BaseProps = { bar: string }
226
+ type Props = BaseProps & { foo: string }
227
+
228
+ class Component extends React.Component<Props & {
229
+ isDefaultChecked: boolean,
230
+ }> {
231
+ static defaultProps = {
232
+ bar: 'baz',
233
+ }
234
+ }
235
+ `
236
+ } ,
221
237
{
222
238
name : 'with spread in type annotation' ,
223
239
typeSystem : 'flow' ,
You can’t perform that action at this time.
0 commit comments