Fix yarn lint:types when matrix-js-sdk is not yarn linked. (#30612)

* Add missing dependencies on `@types` packages

Because we import the typescript source from matrix-js-sdk rather than the
`.d.ts` files, `tsc` ends up type-checking the js-sdk source. That means that
we need to have the `@types` packages that js-sdk needs.

* Add missing type definitions for `setInterval` and `setTimeout`

Our source assumes that `setTimeout` returns a number, not a
`Timeout`. If we `yarn link` js-sdk, then (somehow) we end up using the
definitions from there, but it's not really correct.

* Configure knip to ignore new deps
This commit is contained in:
Richard van der Hoff
2025-08-27 14:13:00 +01:00
committed by GitHub
parent 87b4918d34
commit a003ebcb35
4 changed files with 26 additions and 0 deletions

View File

@@ -71,6 +71,13 @@ type ElectronChannel =
| "serverSupportedVersions";
declare global {
// use `number` as the return type in all cases for globalThis.set{Interval,Timeout},
// so we don't accidentally use the methods on NodeJS.Timeout - they only exist in a subset of environments.
// The overload for clear{Interval,Timeout} is resolved as expected.
// We use `ReturnType<typeof setTimeout>` in the code to be agnostic of if this definition gets loaded.
function setInterval(handler: TimerHandler, timeout: number, ...arguments: any[]): number;
function setTimeout(handler: TimerHandler, timeout: number, ...arguments: any[]): number;
interface Window {
mxSendRageshake: (text: string, withLogs?: boolean) => void;
matrixLogger: typeof logger;