From c8ad9c2494b9f761aaa63643e4a017635be291ae Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Sat, 27 Dec 2025 14:53:50 -0600 Subject: [PATCH 1/5] fix: Type errors in jsx-runtime --- jsx-runtime/src/index.d.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/jsx-runtime/src/index.d.ts b/jsx-runtime/src/index.d.ts index 46649e8bdf..65b7d5421a 100644 --- a/jsx-runtime/src/index.d.ts +++ b/jsx-runtime/src/index.d.ts @@ -6,14 +6,15 @@ import { ComponentChild, ComponentChildren, VNode, - Attributes + Attributes, + HTMLAttributes, + SVGAttributes } from 'preact'; -import { JSXInternal } from '../../src/jsx'; export function jsx( type: string, - props: JSXInternal.HTMLAttributes & - JSXInternal.SVGAttributes & + props: HTMLAttributes & + SVGAttributes & Record & { children?: ComponentChild }, key?: string ): VNode; @@ -25,8 +26,8 @@ export function jsx

( export function jsxs( type: string, - props: JSXInternal.HTMLAttributes & - JSXInternal.SVGAttributes & + props: HTMLAttributes & + SVGAttributes & Record & { children?: ComponentChild[] }, key?: string ): VNode; @@ -38,8 +39,8 @@ export function jsxs

( export function jsxDEV( type: string, - props: JSXInternal.HTMLAttributes & - JSXInternal.SVGAttributes & + props: HTMLAttributes & + SVGAttributes & Record & { children?: ComponentChildren }, key?: string ): VNode; @@ -58,5 +59,3 @@ export function jsxAttr(name: string, value: any): string | null; export function jsxEscape( value: T ): string | null | VNode | Array; - -export { JSXInternal as JSX }; From b7ca0366f5efe0fb6f69e7d20128cae48285d3a7 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Sat, 27 Dec 2025 14:54:13 -0600 Subject: [PATCH 2/5] chore: Disable non-functional linting --- jsconfig-lint.json | 16 ---------------- package.json | 1 - 2 files changed, 17 deletions(-) delete mode 100644 jsconfig-lint.json diff --git a/jsconfig-lint.json b/jsconfig-lint.json deleted file mode 100644 index 0658e4649d..0000000000 --- a/jsconfig-lint.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "./jsconfig.json", - "compilerOptions": { - "skipLibCheck": true, - "noEmit": true, - "typeRoots": ["./node_modules/@types", "./node_modules", "./types"] - }, - "include": [ - "src/**/*", - "hooks/src/**/*", - "compat/**/*.d.ts", - "jsx-runtime/**/*.d.ts", - "types/**/*.d.ts" - ], - "exclude": ["**/node_modules/**", "node_modules"] -} diff --git a/package.json b/package.json index a20bd071ce..36e86e2ec1 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,6 @@ "test:ts:core": "tsc -p test/ts/", "test:ts:compat": "tsc -p compat/test/ts/", "lint": "run-s oxlint tsc", - "tsc": "tsc -p jsconfig-lint.json", "oxlint": "oxlint -c oxlint.json src test/browser test/node test/shared debug compat hooks test-utils", "format": "biome format --write .", "format:check": "biome format ." From 97918b566eeabd71dac8b2b8db50c4bb2168ef2f Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Sat, 27 Dec 2025 15:54:32 -0600 Subject: [PATCH 3/5] revert: Bring back linting --- jsconfig-lint.json | 19 +++++++++++++++++++ package.json | 1 + 2 files changed, 20 insertions(+) create mode 100644 jsconfig-lint.json diff --git a/jsconfig-lint.json b/jsconfig-lint.json new file mode 100644 index 0000000000..b3999164d6 --- /dev/null +++ b/jsconfig-lint.json @@ -0,0 +1,19 @@ +{ + "extends": "./jsconfig.json", + "compilerOptions": { + // More modern settings as Vite & Vitest require them and TS doesn't allow + // silencing errors from `node_modules` alone. + "moduleResolution": "Node16", + "target": "ES2015", + "module": "Node16", + "checkJs": false + }, + "include": [ + "src/**/*", + "hooks/src/**/*", + "compat/**/*.d.ts", + "jsx-runtime/**/*.d.ts", + "types/**/*.d.ts" + ], + "exclude": ["**/node_modules/**", "node_modules"] +} diff --git a/package.json b/package.json index 36e86e2ec1..a20bd071ce 100644 --- a/package.json +++ b/package.json @@ -140,6 +140,7 @@ "test:ts:core": "tsc -p test/ts/", "test:ts:compat": "tsc -p compat/test/ts/", "lint": "run-s oxlint tsc", + "tsc": "tsc -p jsconfig-lint.json", "oxlint": "oxlint -c oxlint.json src test/browser test/node test/shared debug compat hooks test-utils", "format": "biome format --write .", "format:check": "biome format ." From e2c1c9a5435f512a2cbe2a23056dad45884f0f4b Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Sat, 27 Dec 2025 15:55:00 -0600 Subject: [PATCH 4/5] chore: Adjust linting setup --- compat/server.d.ts | 3 +++ types/events.d.ts | 58 --------------------------------------------- types/weak-key.d.ts | 9 +++++++ 3 files changed, 12 insertions(+), 58 deletions(-) delete mode 100644 types/events.d.ts create mode 100644 types/weak-key.d.ts diff --git a/compat/server.d.ts b/compat/server.d.ts index caad2a5bbb..6a27985c47 100644 --- a/compat/server.d.ts +++ b/compat/server.d.ts @@ -1,3 +1,6 @@ +// @ts-nocheck TS loses its mind over the mixed module systems here. +// It's not ideal, but works at runtime and we're not shipping mixed type definitions. + import { renderToString } from 'preact-render-to-string'; import { renderToPipeableStream } from 'preact-render-to-string/stream-node'; import { renderToReadableStream } from 'preact-render-to-string/stream'; diff --git a/types/events.d.ts b/types/events.d.ts deleted file mode 100644 index 2ec284037d..0000000000 --- a/types/events.d.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Type declaration file to fix the events module errors - */ - -declare module 'events' { - export class EventEmitter { - // Methods - addListener( - event: string | symbol, - listener: (...args: any[]) => void - ): this; - on(event: string | symbol, listener: (...args: any[]) => void): this; - once(event: string | symbol, listener: (...args: any[]) => void): this; - removeListener( - event: string | symbol, - listener: (...args: any[]) => void - ): this; - off(event: string | symbol, listener: (...args: any[]) => void): this; - removeAllListeners(event?: string | symbol): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string | symbol): Function[]; - rawListeners(event: string | symbol): Function[]; - emit(event: string | symbol, ...args: any[]): boolean; - listenerCount(event: string | symbol): number; - prependListener( - event: string | symbol, - listener: (...args: any[]) => void - ): this; - prependOnceListener( - event: string | symbol, - listener: (...args: any[]) => void - ): this; - eventNames(): (string | symbol)[]; - - // For TypeScript errors in events module - static listenerCount(emitter: EventEmitter, event: string | symbol): number; - static defaultMaxListeners: number; - } - - // Extended Error type to include properties used in events.js - interface ErrorWithEventProperties extends Error { - context?: any; - emitter?: any; - type?: string | symbol; - count?: number; - } - - // For onceWrapper - interface OnceWrapper extends Function { - listener?: Function; - target?: any; - type?: string | symbol; - wrapFn?: Function; - } - - export default EventEmitter; -} diff --git a/types/weak-key.d.ts b/types/weak-key.d.ts new file mode 100644 index 0000000000..0419ab7b07 --- /dev/null +++ b/types/weak-key.d.ts @@ -0,0 +1,9 @@ +declare global { + export interface WeakKeyTypes { + object: object; + } + + export type WeakKey = WeakKeyTypes[keyof WeakKeyTypes]; +} + +export {}; From 6c33d1f679c4b470751675fbfb6bb923e6f79147 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Sat, 27 Dec 2025 16:31:49 -0600 Subject: [PATCH 5/5] revert: Continue re-exporting JSX namespace from `jsx-runtime` --- jsx-runtime/src/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jsx-runtime/src/index.d.ts b/jsx-runtime/src/index.d.ts index 65b7d5421a..29417c8bdd 100644 --- a/jsx-runtime/src/index.d.ts +++ b/jsx-runtime/src/index.d.ts @@ -10,6 +10,7 @@ import { HTMLAttributes, SVGAttributes } from 'preact'; +import { JSXInternal } from '../../src/jsx'; export function jsx( type: string, @@ -59,3 +60,5 @@ export function jsxAttr(name: string, value: any): string | null; export function jsxEscape( value: T ): string | null | VNode | Array; + +export { JSXInternal as JSX };