Summary
In packages/cli/src/Writers/DataTransformers.ts, the splitComponentByConcern function defaults props to an empty array when the source component has no props:
const api: ComponentApiData = {
title: data.title,
anatomy: data.anatomy,
props: data.props || [], // should be {}
metadata: data.metadata
};
The TypeScript interface also types it incorrectly:
export interface ComponentApiData {
props: any[]; // should be Record<string, any> or object
}
Root cause
The Anova Figma plugin correctly returns undefined for components with no props (via Props.data() returning undefined when _items is empty). When the CLI runs in --split-concerns mode, splitComponentByConcern fills in the missing key with [] instead of {}.
Impact
The schema (packages/schema/schema/component.schema.json) defines Props as:
"Props": {
"type": "object",
"additionalProperties": { "$ref": "#/definitions/AnyProp" }
}
Downstream consumers calling Object.keys(configurations) or similar object operations on the renamed props field get unexpected behavior when it's an array.
Observed in production for egdsDivider and egdsSearchBarExperimental — both are components with no Figma properties.
Suggested fix
export interface ComponentApiData {
props: Record<string, any>;
}
// In splitComponentByConcern:
props: data.props || {},
// Same for extractApiFromSubcomponents:
props: data.props || {},
Same issue in SubcomponentApiData
export interface SubcomponentApiData {
props: any[]; // also typed as array
}
And in extractApiFromSubcomponents:
props: data.props || [], // also defaults to []
Summary
In
packages/cli/src/Writers/DataTransformers.ts, thesplitComponentByConcernfunction defaultspropsto an empty array when the source component has no props:The TypeScript interface also types it incorrectly:
Root cause
The Anova Figma plugin correctly returns
undefinedfor components with no props (viaProps.data()returningundefinedwhen_itemsis empty). When the CLI runs in--split-concernsmode,splitComponentByConcernfills in the missing key with[]instead of{}.Impact
The schema (
packages/schema/schema/component.schema.json) definesPropsas:Downstream consumers calling
Object.keys(configurations)or similar object operations on the renamedpropsfield get unexpected behavior when it's an array.Observed in production for
egdsDividerandegdsSearchBarExperimental— both are components with no Figma properties.Suggested fix
Same issue in SubcomponentApiData
And in
extractApiFromSubcomponents: