Skip to content

Commit

Permalink
fix: we are sure about type if parent checked it
Browse files Browse the repository at this point in the history
Type delta calculation here is needed for discriminator to be sure
that we can compile.
  • Loading branch information
ChALkeR committed Jan 25, 2024
1 parent b549d02 commit add7790
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,10 @@ const compileSchema = (schema, root, opts, scope, basePathRoot = '') => {
evaluateDelta({ type: [current.type] })
return null
}
if (parentCheckedType(...typearr)) return null
if (parentCheckedType(...typearr)) {
evaluateDelta({ type: typearr })
return null
}
const filteredTypes = typearr.filter((t) => typeApplicable(t))
if (filteredTypes.length === 0) fail('No valid types possible')
evaluateDelta({ type: typearr }) // can be safely done here, filteredTypes already prepared
Expand Down

0 comments on commit add7790

Please sign in to comment.