diff --git a/knip.ts b/knip.ts index e129c11481..dd283a0580 100644 --- a/knip.ts +++ b/knip.ts @@ -42,6 +42,13 @@ export default { "util", // Embedded into webapp "@element-hq/element-call-embedded", + + // Used by matrix-js-sdk, which means we have to include them as a + // dependency so that // we can run `tsc` (since we import the typescript + // source of js-sdk, rather than the transpiled and annotated JS like you + // would with a normal library). + "@types/content-type", + "@types/sdp-transform", ], ignoreBinaries: [ // Used in scripts & workflows diff --git a/package.json b/package.json index aa21689838..6af83533a1 100644 --- a/package.json +++ b/package.json @@ -203,6 +203,7 @@ "@testing-library/react": "^16.0.0", "@testing-library/user-event": "^14.5.2", "@types/commonmark": "^0.27.4", + "@types/content-type": "^1.1.9", "@types/counterpart": "^0.18.1", "@types/css-tree": "^2.3.8", "@types/diff-match-patch": "^1.0.32", @@ -226,6 +227,7 @@ "@types/react-dom": "19.1.7", "@types/react-transition-group": "^4.4.0", "@types/sanitize-html": "2.16.0", + "@types/sdp-transform": "^2.4.10", "@types/semver": "^7.5.8", "@types/tar-js": "^0.3.5", "@types/ua-parser-js": "^0.7.36", diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index 77e57e1434..a8f132c84b 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -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` 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; diff --git a/yarn.lock b/yarn.lock index 6237354a3c..043ab0c180 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3965,6 +3965,11 @@ dependencies: "@types/node" "*" +"@types/content-type@^1.1.9": + version "1.1.9" + resolved "https://registry.yarnpkg.com/@types/content-type/-/content-type-1.1.9.tgz#a0240a8141b33549ac0ca6847f4b801580012bca" + integrity sha512-Hq9IMnfekuOCsEmYl4QX2HBrT+XsfXiupfrLLY8Dcf3Puf4BkBOxSbWYTITSOQAhJoYPBez+b4MJRpIYL65z8A== + "@types/counterpart@^0.18.1": version "0.18.4" resolved "https://registry.yarnpkg.com/@types/counterpart/-/counterpart-0.18.4.tgz#e3e331b7e0d5496873d417839f3b2bbcf555bb73" @@ -4334,6 +4339,11 @@ dependencies: htmlparser2 "^8.0.0" +"@types/sdp-transform@^2.4.10": + version "2.4.10" + resolved "https://registry.yarnpkg.com/@types/sdp-transform/-/sdp-transform-2.4.10.tgz#f4e60fbc97f66527f221a3ae092be7c465c55f56" + integrity sha512-999diMTpgQGt+dj+tAEQNvBAJYkOip83NJn1RruqNmqeLYNZpQnUX/YrugR+ekXvdJ9pdkZtYg1jiM3mG3NhRg== + "@types/seedrandom@^3.0.8": version "3.0.8" resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-3.0.8.tgz#61cc8ed88f93a3c31289c295e6df8ca40be42bdf"