Skip to content

Commit a68833b

Browse files
committed
update API
1 parent aea36ea commit a68833b

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

packages/react-icons/src/createIcon.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,26 @@ export interface IconDefinitionBase {
1414
svgClassName?: string;
1515
}
1616

17-
/** Icon metadata using the current `svgPathData` field name. */
18-
export interface IconDefinitionWithSvgPathData extends IconDefinitionBase {
19-
svgPathData: string | SVGPathObject[];
20-
}
21-
2217
/**
23-
* @deprecated Use {@link IconDefinitionWithSvgPathData} with `svgPathData` instead.
18+
* SVG path content for one icon variant (default or rh-ui). At runtime at least one of
19+
* `svgPathData` or `svgPath` must be set; if both are present, `svgPathData` is used.
2420
*/
25-
export interface IconDefinitionWithSvgPath extends IconDefinitionBase {
26-
svgPath: string | SVGPathObject[];
21+
export interface IconDefinition extends IconDefinitionBase {
22+
svgPathData?: string | SVGPathObject[];
23+
/**
24+
* @deprecated Use {@link IconDefinition.svgPathData} instead.
25+
*/
26+
svgPath?: string | SVGPathObject[];
2727
}
2828

29-
/** Describes SVG path content for one icon variant (default or rh-ui). */
30-
export type IconDefinition = IconDefinitionWithSvgPathData | IconDefinitionWithSvgPath;
29+
/** Narrows {@link IconDefinition} to the preferred shape with required `svgPathData`. */
30+
export type IconDefinitionWithSvgPathData = Required<Pick<IconDefinition, 'svgPathData'>> & IconDefinition;
31+
32+
/**
33+
* @deprecated Use {@link IconDefinition} with `svgPathData` instead.
34+
* Narrows {@link IconDefinition} to the legacy shape with required `svgPath`.
35+
*/
36+
export type IconDefinitionWithSvgPath = Required<Pick<IconDefinition, 'svgPath'>> & IconDefinition;
3137

3238
/** When passing `icon` or `rhUiIcon` keys (nested form), `icon` is required at runtime. */
3339
export interface CreateIconProps {

0 commit comments

Comments
 (0)