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/jsconfig-lint.json b/jsconfig-lint.json index 0658e4649d..b3999164d6 100644 --- a/jsconfig-lint.json +++ b/jsconfig-lint.json @@ -1,9 +1,12 @@ { "extends": "./jsconfig.json", "compilerOptions": { - "skipLibCheck": true, - "noEmit": true, - "typeRoots": ["./node_modules/@types", "./node_modules", "./types"] + // 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/**/*", diff --git a/jsx-runtime/src/index.d.ts b/jsx-runtime/src/index.d.ts index 46649e8bdf..29417c8bdd 100644 --- a/jsx-runtime/src/index.d.ts +++ b/jsx-runtime/src/index.d.ts @@ -6,14 +6,16 @@ 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 +27,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 +40,8 @@ export function jsxs

( export function jsxDEV( type: string, - props: JSXInternal.HTMLAttributes & - JSXInternal.SVGAttributes & + props: HTMLAttributes & + SVGAttributes & Record & { children?: ComponentChildren }, key?: string ): VNode; 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 {};