8000 replace `keyof ReactSVG` with `SVGElementType` (#2668) · lucide-icons/lucide@961404d · GitHub
[go: up one dir, main page]

Skip to content

Commit 961404d

Browse files
aslilacericfennis
andauthored
replace keyof ReactSVG with SVGElementType (#2668)
* 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>
1 parent f3100b8 commit 961404d

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

packages/lucide-react-native/src/createLucideIcon.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
forwardRef,
3-
createElement,
4-
ReactSVG,
5-
FunctionComponent,
6-
ForwardRefExoticComponent,
7-
} from 'react';
1+
import { forwardRef, createElement, FunctionComponent } from 'react';
82
import * as NativeSvg from 'react-native-svg';
93
import defaultAttributes, { childDefaultAttributes } from './defaultAttributes';
104
import { IconNode, LucideIcon, LucideProps } from './types';

packages/lucide-react-native/src/types.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
import type { ForwardRefExoticComponent, ReactSVG } from 'react';
1+
import type { ForwardRefExoticComponent } from 'react';
22
import type { SvgProps } from 'react-native-svg';
33

4-
export type IconNode = [elementName: keyof ReactSVG, attrs: Record<string, string>][];
4+
/**
5+
* A reduced version of `SVGElementType` from @types/react. This type was added
6+
* with the release of React 19, and is included here in order to support usage
7+
* with older versions.
8+
*/
9+
type SVGElementType =
10+
| 'circle'
11+
| 'ellipse'
12+
| 'g'
13+
| 'line'
14+
| 'path'
15+
| 'polygon'
16+
| 'polyline'
17+
| 'rect';
18+
19+
export type IconNode = [elementName: SVGElementType, attrs: Record<string, string>][];
520

621
export interface LucideProps extends SvgProps {
722
size?: string | number;

packages/lucide-react/src/types.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
import { ReactSVG, SVGProps, ForwardRefExoticComponent, RefAttributes } from 'react';
1+
import type { SVGProps, ForwardRefExoticComponent, RefAttributes } from 'react';
22

3-
export type IconNode = [elementName: keyof ReactSVG, attrs: Record<string, string>][];
3+
/**
4+
* A reduced version of `SVGElementType` from @types/react. This type was added
5+
* with the release of React 19, and is included here in order to support usage
6+
* with older versions.
7+
*/
8+
type SVGElementType =
9+
| 'circle'
10+
| 'ellipse'
11+
| 'g'
12+
| 'line'
13+
| 'path'
14+
| 'polygon'
15+
| 'polyline'
16+
| 'rect';
17+
18+
export type IconNode = [elementName: SVGElementType, attrs: Record<string, string>][];
419

520
export type SVGAttributes = Partial<SVGProps<SVGSVGElement>>;
621
type ElementAttributes = RefAttributes<SVGSVGElement> & SVGAttributes;

0 commit comments

Comments
 (0)
0