From e5f440d8bebacba480fc7d2210cce72eb15741a2 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Mon, 31 Aug 2026 19:20:03 +0300 Subject: [PATCH] fix(fig): guard component property definitions --- tests/engine/io/fig/roundtrip/helpers.ts | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/engine/io/fig/roundtrip/helpers.ts b/tests/engine/io/fig/roundtrip/helpers.ts index b6ac7ec27..79e592efb 100644 --- a/tests/engine/io/fig/roundtrip/helpers.ts +++ b/tests/engine/io/fig/roundtrip/helpers.ts @@ -87,17 +87,20 @@ function sameNodeReference(ctx: VerifierContext, a: string, b: string): boolean function isComponentPropertyDefinitions(value: unknown): value is ComponentPropertyDefinition[] { if (!Array.isArray(value)) return false - return value.every( - (entry) => - typeof entry === 'object' && - entry !== null && - typeof entry.id === 'string' && - typeof entry.name === 'string' && - (entry.type === 'VARIANT' || - entry.type === 'TEXT' || - entry.type === 'BOOLEAN' || - entry.type === 'INSTANCE_SWAP') && - typeof entry.defaultValue === 'string' + return value.every(isComponentPropertyDefinition) +} + +function isComponentPropertyDefinition(value: unknown): value is ComponentPropertyDefinition { + if (!value || typeof value !== 'object') return false + const candidate = value as Partial + return ( + typeof candidate.id === 'string' && + typeof candidate.name === 'string' && + (candidate.type === 'VARIANT' || + candidate.type === 'TEXT' || + candidate.type === 'BOOLEAN' || + candidate.type === 'INSTANCE_SWAP') && + typeof candidate.defaultValue === 'string' ) }