From ee17d562f77e6415e2bc7324f3159acfa08eef0c Mon Sep 17 00:00:00 2001 From: szecket Date: Mon, 28 Apr 2025 17:29:42 -0400 Subject: [PATCH] figma-inspector: added stricter types --- .../backend/utils/export-variables.ts | 53 ++++++++----------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/tools/figma-inspector/backend/utils/export-variables.ts b/tools/figma-inspector/backend/utils/export-variables.ts index 947ff355d..9d40be742 100644 --- a/tools/figma-inspector/backend/utils/export-variables.ts +++ b/tools/figma-inspector/backend/utils/export-variables.ts @@ -543,7 +543,7 @@ interface PropertyInstance { function generateStructsAndInstances( variableTree: VariableNode, collectionName: string, - collectionData: any, // Using any for now, but ideally define a proper interface + collectionData: CollectionData, // using strict type interface ): { structs: string; instances: string; @@ -1069,6 +1069,19 @@ function generateStructsAndInstances( instances: instancesCode, }; } +interface VariableModeData { + value: string; + type: string; + refId?: string; + comment?: string; +} + +interface CollectionData { + name: string; + formattedName: string; + modes: Set; + variables: Map>; +} // For Figma Plugin - Export function with hierarchical structure // Export each collection to a separate virtual file @@ -1093,26 +1106,7 @@ export async function exportFigmaVariablesToSeparateFiles( const exportedFiles: Array<{ name: string; content: string }> = []; // First, initialize the collection structure for ALL collections - const collectionStructure = new Map< - string, - { - name: string; - formattedName: string; - modes: Set; - variables: Map< - string, - Map< - string, - { - value: string; - type: string; - refId?: string; - comment?: string; - } - > - >; - } - >(); + const collectionStructure = new Map(); // Build a global map of variable paths const variablePathsById = new Map< @@ -1193,17 +1187,12 @@ export async function exportFigmaVariablesToSeparateFiles( .get(collectionName)! .variables.has(sanitizedRowName) ) { - collectionStructure.get(collectionName)!.variables.set( - sanitizedRowName, - new Map< - string, - { - value: string; - type: string; - refId?: string; - } - >(), - ); + collectionStructure + .get(collectionName)! + .variables.set( + sanitizedRowName, + new Map(), + ); } // Process values for each mode