From 24489a1efb498a706dcda53c4e176a0dc4cde954 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Mon, 28 Sep 2026 08:08:16 +0200 Subject: [PATCH 1/2] feat: allow Preact v11 as a peer dependency of wouter-preact --- bun.lock | 2 +- packages/wouter-preact/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bun.lock b/bun.lock index 1e1496f6..2c3e1828 100644 --- a/bun.lock +++ b/bun.lock @@ -64,7 +64,7 @@ "wouter": "*", }, "peerDependencies": { - "preact": "^10.0.0", + "preact": "^10.0.0 || ^11.0.0-0", }, }, }, diff --git a/packages/wouter-preact/package.json b/packages/wouter-preact/package.json index 0df21c98..f4be2d79 100644 --- a/packages/wouter-preact/package.json +++ b/packages/wouter-preact/package.json @@ -63,7 +63,7 @@ }, "license": "Unlicense", "peerDependencies": { - "preact": "^10.0.0" + "preact": "^10.0.0 || ^11.0.0-0" }, "dependencies": { "regexparam": "^3.0.0" From 15a6fefad324aa382c90e71c8a3f4523f79b008f Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Mon, 28 Sep 2026 08:08:25 +0200 Subject: [PATCH 2/2] fix(types): resolve wouter-preact Link types on Preact 11 Preact 11 no longer exposes DOM attribute and event handler types such as HTMLAttributes and MouseEventHandler on the JSX namespace. Derive the Link attributes from JSX.IntrinsicElements["a"] and declare the asChild click handler locally, so the types resolve on both Preact 10 and 11. --- packages/wouter-preact/types/index.d.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/wouter-preact/types/index.d.ts b/packages/wouter-preact/types/index.d.ts index d615e7fb..e6100798 100644 --- a/packages/wouter-preact/types/index.d.ts +++ b/packages/wouter-preact/types/index.d.ts @@ -6,6 +6,7 @@ import { FunctionComponent, ComponentType, ComponentChildren, + Ref, } from "preact"; import { @@ -105,16 +106,30 @@ type AsChildProps = | ({ asChild?: false } & DefaultElementProps) | ({ asChild: true } & ComponentProps); -type HTMLLinkAttributes = Omit & { +// Preact 11 no longer exposes DOM attribute and event handler types on the +// `JSX` namespace, so derive them in a way that works with Preact 10 and 11. +type HTMLLinkAttributes = Omit< + JSX.IntrinsicElements["a"], + "className" | "ref" +> & { className?: string | undefined | ((isActive: boolean) => string | undefined); + ref?: Ref; }; +type ElementMouseEventHandler = { + bivarianceHack( + event: Omit & { + readonly currentTarget: Element; + } + ): void; +}["bivarianceHack"]; + export type LinkProps = NavigationalProps & AsChildProps< Omit & { children: ComponentChildren; - onClick?: JSX.MouseEventHandler; + onClick?: ElementMouseEventHandler; }, HTMLLinkAttributes >;