fix(lucide-preact): add Preact v11 compatibility (#4924)

* fix(lucide-preact): import `SVGAttributes` and `SignalLike` from `preact`

`LucideProps` extended `JSX.SVGAttributes` and `createLucideIcon` used
`JSX.SignalLike`. Preact 10 marks both JSX aliases as deprecated in favour
of the top-level exports, and Preact 11 removes them: its `JSX` namespace
only keeps what TypeScript needs for JSX checking.

Against Preact 11 the package fails `tsc` (TS2694), and the published
`.d.ts` resolves `LucideProps` to an error type. Consumers with
`skipLibCheck: true` see no error, but every icon then accepts unknown
props and event handler parameters become implicit `any`.

The top-level `SVGAttributes` and `SignalLike` exports already exist in
Preact 10.27.2, the current peer floor, and are identical to the JSX
aliases there, so the props type does not change for Preact 10 users.

* fix(lucide-preact): add Preact v11 compatibility

Widen the `preact` peer range to `^10.27.2 || ^11.0.0-0`. The `-0` lets
the 11.0.0 release candidates install without peer warnings and still
covers every 11.x release.

The dev dependency stays on Preact 10. The lockfile does not record
workspace peer ranges, so it is unchanged.
This commit is contained in:
Jovi De Croock
2026-10-02 13:15:43 +02:00
committed by GitHub
parent 05eacffce6
commit 309f440724
3 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -62,6 +62,6 @@
"vite": "^7.3.6"
},
"peerDependencies": {
"preact": "^10.27.2"
"preact": "^10.27.2 || ^11.0.0-0"
}
}
@@ -1,4 +1,4 @@
import { h, JSX } from 'preact';
import { h, type SignalLike } from 'preact';
import { mergeClasses, toLucideIconData, toPascalCase } from '@lucide/shared';
import Icon from './Icon';
import type { LucideIcon, LucideIconData, LucideIconNode, LucideProps } from './types';
@@ -41,7 +41,7 @@ function createLucideIcon(
{
...props,
icon: iconData,
class: mergeClasses<string | JSX.SignalLike<string | undefined>>(classes, className),
class: mergeClasses<string | SignalLike<string | undefined>>(classes, className),
},
children,
);
+2 -2
View File
@@ -1,4 +1,4 @@
import { type FunctionComponent, type JSX } from 'preact';
import { type FunctionComponent, type SVGAttributes } from 'preact';
import type {
LucideIconData as SharedLucideIconData,
LucideIconNode as SharedLucideIconNode,
@@ -13,7 +13,7 @@ export type LucideIconData = SharedLucideIconData;
*/
export type IconNode = LucideIconNode[];
export interface LucideProps extends Partial<Omit<JSX.SVGAttributes, 'ref' | 'size'>> {
export interface LucideProps extends Partial<Omit<SVGAttributes, 'ref' | 'size'>> {
color?: string;
size?: string | number;
width?: string | number;