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>
This commit is contained in:
ケイラ
2025-01-18 08:35:52 -07:00
committed by GitHub
parent f3100b8af1
commit 961404d5cc
3 changed files with 35 additions and 11 deletions

View File

@@ -1,10 +1,4 @@
import { import { forwardRef, createElement, FunctionComponent } from 'react';
forwardRef,
createElement,
ReactSVG,
FunctionComponent,
ForwardRefExoticComponent,
} from 'react';
import * as NativeSvg from 'react-native-svg'; import * as NativeSvg from 'react-native-svg';
import defaultAttributes, { childDefaultAttributes } from './defaultAttributes'; import defaultAttributes, { childDefaultAttributes } from './defaultAttributes';
import { IconNode, LucideIcon, LucideProps } from './types'; import { IconNode, LucideIcon, LucideProps } from './types';

View File

@@ -1,7 +1,22 @@
import type { ForwardRefExoticComponent, ReactSVG } from 'react'; import type { ForwardRefExoticComponent } from 'react';
import type { SvgProps } from 'react-native-svg'; 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 { export interface LucideProps extends SvgProps {
size?: string | number; size?: string | number;

View File

@@ -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>>; export type SVGAttributes = Partial<SVGProps<SVGSVGElement>>;
type ElementAttributes = RefAttributes<SVGSVGElement> & SVGAttributes; type ElementAttributes = RefAttributes<SVGSVGElement> & SVGAttributes;