diff --git a/packages/behavior/type.js b/packages/behavior/type.js index 8bd52e0..3d8fad0 100644 --- a/packages/behavior/type.js +++ b/packages/behavior/type.js @@ -57,9 +57,13 @@ export const invertedDigraph = memoize(() => { export const candidates = (description, type) => { const inverted = invertedDigraph(); + const typeParts = type.split('|'); + if (typeParts.length > 1) { + return typeParts.reduce((r, typePart) => r.concat(candidates(description, typePart)), []); + } const types = (inverted[type] || []).concat(type); const {children} = description; - return 'any' === type + const c = 'any' === type ? Object.keys(children) : Object.entries(children) .reduce((r, [key, {type}]) => ( @@ -69,6 +73,7 @@ export const candidates = (description, type) => { : [] ) ), []); + return c; }; export function description(type, instance) {