Skip to content

Commit

Permalink
replace keyof ReactSVG with SVGElementType (#2668)
Browse files Browse the repository at this point in the history
* replace `keyof ReactSVG` with `SVGElementType`

* define `SVGElementType` locally

* 🧹

* update comments

* Format types.ts

* Update types.ts

* Update types.ts

---------

Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
  • Loading branch information
aslilac and ericfennis authored Jan 18, 2025
1 parent f3100b8 commit 961404d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
8 changes: 1 addition & 7 deletions packages/lucide-react-native/src/createLucideIcon.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
forwardRef,
createElement,
ReactSVG,
FunctionComponent,
ForwardRefExoticComponent,
} from 'react';
import { forwardRef, createElement, FunctionComponent } from 'react';
import * as NativeSvg from 'react-native-svg';
import defaultAttributes, { childDefaultAttributes } from './defaultAttributes';
import { IconNode, LucideIcon, LucideProps } from './types';
Expand Down
19 changes: 17 additions & 2 deletions packages/lucide-react-native/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import type { ForwardRefExoticComponent, ReactSVG } from 'react';
import type { ForwardRefExoticComponent } from 'react';
import type { SvgProps } from 'react-native-svg';

export type IconNode = [elementName: keyof ReactSVG, attrs: Record<string, string>][];
/**
* A reduced version of `SVGElementType` from @types/react. This type was added
* with the release of React 19, and is included here in order to support usage
* with older versions.
*/
type SVGElementType =
| 'circle'
| 'ellipse'
| 'g'
| 'line'
| 'path'
| 'polygon'
| 'polyline'
| 'rect';

export type IconNode = [elementName: SVGElementType, attrs: Record<string, string>][];

export interface LucideProps extends SvgProps {
size?: string | number;
Expand Down
19 changes: 17 additions & 2 deletions packages/lucide-react/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import { ReactSVG, SVGProps, ForwardRefExoticComponent, RefAttributes } from 'react';
import type { SVGProps, ForwardRefExoticComponent, RefAttributes } from 'react';

export type IconNode = [elementName: keyof ReactSVG, attrs: Record<string, string>][];
/**
* A reduced version of `SVGElementType` from @types/react. This type was added
* with the release of React 19, and is included here in order to support usage
* with older versions.
*/
type SVGElementType =
| 'circle'
| 'ellipse'
| 'g'
| 'line'
| 'path'
| 'polygon'
| 'polyline'
| 'rect';

export type IconNode = [elementName: SVGElementType, attrs: Record<string, string>][];

export type SVGAttributes = Partial<SVGProps<SVGSVGElement>>;
type ElementAttributes = RefAttributes<SVGSVGElement> & SVGAttributes;
Expand Down

0 comments on commit 961404d

Please sign in to comment.