(typeObj, propObj, parentType)
| 254 | }); |
| 255 | |
| 256 | const getUnion = (typeObj, propObj, parentType) => { |
| 257 | let name = 'union', |
| 258 | value; |
| 259 | |
| 260 | // Union only do base types & DashComponent types |
| 261 | value = typeObj.types |
| 262 | .filter(t => { |
| 263 | let typeName = t.intrinsicName; |
| 264 | if (!typeName) { |
| 265 | if (t.members) { |
| 266 | typeName = 'object'; |
| 267 | } else { |
| 268 | const typeString = checker.typeToString(t); |
| 269 | if (typeString === 'DashComponent') { |
| 270 | typeName = 'node'; |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | if (t.value) { |
| 275 | // A literal value |
| 276 | return true; |
| 277 | } |
| 278 | return ( |
| 279 | unionSupport.includes(typeName) || |
| 280 | isArray(checker.typeToString(t)) |
| 281 | ); |
| 282 | }); |
| 283 | value = value.map(t => t.value ? {name: 'literal', value: t.value} : getPropType(t, propObj, parentType)); |
| 284 | |
| 285 | // de-dupe any types in this union |
| 286 | value = value.reduce((acc, t) => { |
| 287 | const key = `${t.name}:${t.value}`; |
| 288 | if (!acc.seen.has(key)) { |
| 289 | acc.seen.add(key); |
| 290 | acc.result.push(t); |
| 291 | } |
| 292 | return acc; |
| 293 | }, { seen: new Set(), result: [] }).result; |
| 294 | |
| 295 | if (!value.length) { |
| 296 | name = 'any'; |
| 297 | value = undefined; |
| 298 | } |
| 299 | return { |
| 300 | name, |
| 301 | value |
| 302 | }; |
| 303 | }; |
| 304 | |
| 305 | const getPropTypeName = propName => { |
| 306 | if (propName.includes('=>') || propName === 'Function') { |
no test coverage detected
searching dependent graphs…