From add77903e9bc9cd4cbb805b6e8e438155438f5f0 Mon Sep 17 00:00:00 2001 From: Nikita Skovoroda Date: Thu, 25 Jan 2024 16:30:23 +0300 Subject: [PATCH] fix: we are sure about type if parent checked it Type delta calculation here is needed for discriminator to be sure that we can compile. --- src/compile.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compile.js b/src/compile.js index 7a9f8ae..aa05996 100644 --- a/src/compile.js +++ b/src/compile.js @@ -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