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:
committed by
GitHub
parent
87b4918d34
commit
a003ebcb35
7
src/@types/global.d.ts
vendored
7
src/@types/global.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user