From e2bea57964139fb230e8538fb0dbf63802f3a089 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 11:41:19 +0000 Subject: [PATCH 1/5] Initial plan From 67dc42f2eed57c42aaf4f17bc7582a46ed5af724 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 11:45:18 +0000 Subject: [PATCH 2/5] Fix all TypeScript type checking errors Co-authored-by: ayushmanchhabra <14110965+ayushmanchhabra@users.noreply.github.com> --- @types/yauzl-promise/index.d.ts | 22 ++++++++++++++++++++++ package-lock.json | 26 ++++++++++++++++++++++++++ package.json | 2 ++ src/decompress.js | 3 ++- src/ffmpeg.js | 1 + src/main.js | 6 +++++- src/node.js | 1 + src/request.js | 2 +- tsconfig.json | 10 +++++++++- 9 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 @types/yauzl-promise/index.d.ts diff --git a/@types/yauzl-promise/index.d.ts b/@types/yauzl-promise/index.d.ts new file mode 100644 index 0000000..fcf268e --- /dev/null +++ b/@types/yauzl-promise/index.d.ts @@ -0,0 +1,22 @@ +declare module 'yauzl-promise' { + import { Readable } from 'node:stream'; + + export interface Entry { + filename: string; + externalFileAttributes: number; + openReadStream(): Promise; + } + + export interface ZipFile { + readEntry(): Promise; + close(): Promise; + } + + export function open(path: string): Promise; + + namespace yauzl { + export { Entry, ZipFile, open }; + } + + export default yauzl; +} diff --git a/package-lock.json b/package-lock.json index 0593112..114a013 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,8 @@ }, "devDependencies": { "@eslint/js": "^9.39.2", + "@types/node": "^25.0.10", + "@types/semver": "^7.7.1", "eslint": "^9.39.2", "eslint-plugin-jsdoc": "^62.1.0", "globals": "^17.0.0", @@ -602,6 +604,23 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/node": { + "version": "25.0.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.10.tgz", + "integrity": "sha512-zWW5KPngR/yvakJgGOmZ5vTBemDoSqF3AcV/LrO5u5wTWyEAVVh+IT39G4gtyAkh3CtTZs8aX/yRM82OfzHJRg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.16.0" + } + }, + "node_modules/@types/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA==", + "dev": true, + "license": "MIT" + }, "node_modules/@typescript-eslint/types": { "version": "8.53.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.53.0.tgz", @@ -1803,6 +1822,13 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "dev": true, + "license": "MIT" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 2d0833f..2222c28 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,8 @@ }, "devDependencies": { "@eslint/js": "^9.39.2", + "@types/node": "^25.0.10", + "@types/semver": "^7.7.1", "eslint": "^9.39.2", "eslint-plugin-jsdoc": "^62.1.0", "globals": "^17.0.0", diff --git a/src/decompress.js b/src/decompress.js index 1a95b8a..1666945 100644 --- a/src/decompress.js +++ b/src/decompress.js @@ -87,8 +87,9 @@ async function unzip(zippedFile, cacheDir) { for (const symlinkEntry of symlinks) { let entryPathAbs = path.join(cacheDir, symlinkEntry.filename); const readStream = await symlinkEntry.openReadStream(); + /** @type {Buffer[]} */ const chunks = []; - readStream.on('data', (chunk) => chunks.push(chunk)); + readStream.on('data', (/** @type {Buffer} */ chunk) => chunks.push(chunk)); await new Promise(resolve => readStream.on('end', resolve)); const linkTarget = Buffer.concat(chunks).toString('utf8').trim(); diff --git a/src/ffmpeg.js b/src/ffmpeg.js index 300eacb..bfde934 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -35,4 +35,5 @@ export default async function ffmpeg(downloadUrl, version, platform, arch, cache ); await request(url, ffmpegFileAbs); + return ffmpegFileAbs; } diff --git a/src/main.js b/src/main.js index d269452..e25673f 100644 --- a/src/main.js +++ b/src/main.js @@ -55,7 +55,11 @@ async function get(options) { ) { options.version = manifestData[options.version].slice(1); } else if (semver.valid(semver.coerce(options.version))) { - options.version = semver.coerce(options.version).version; + const coerced = semver.coerce(options.version); + if (coerced === null) { + throw new Error('Expected "options.version" to be "latest", "stable", "lts" or a valid semver version. Received: ' + options.version); + } + options.version = coerced.version; } else { throw new Error('Expected "options.version" to be "latest", "stable", "lts" or a valid semver version. Received: ' + options.version); } diff --git a/src/node.js b/src/node.js index 24829ea..9343026 100644 --- a/src/node.js +++ b/src/node.js @@ -45,4 +45,5 @@ export default async function nw(downloadUrl, version, cacheDir) { ); await request(url, nwFileAbs); + return nwFileAbs; } diff --git a/src/request.js b/src/request.js index dbd9193..ea8e0f8 100644 --- a/src/request.js +++ b/src/request.js @@ -44,7 +44,7 @@ export default function request(url, filePath) { }, (res) => { /* Redirect handling */ - if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { + if (res.statusCode !== undefined && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { cleanup(); const redirectedUrl = new URL(res.headers.location, parsedUrl).toString(); diff --git a/tsconfig.json b/tsconfig.json index ab3f75f..f43f64d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,15 @@ "declaration": true, "emitDeclarationOnly": true, "outDir": "types", - "strict": true + "strict": true, + "target": "ES2020", + "lib": ["ES2020"], + "module": "ESNext", + "moduleResolution": "node", + "types": ["node"], + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "typeRoots": ["./node_modules/@types", "./@types"] }, "include": [ "src/**/*.js" From 653f777c11e963d440869753b2a1f97470616cab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 11:46:50 +0000 Subject: [PATCH 3/5] Simplify yauzl-promise type declarations Co-authored-by: ayushmanchhabra <14110965+ayushmanchhabra@users.noreply.github.com> --- @types/yauzl-promise/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/@types/yauzl-promise/index.d.ts b/@types/yauzl-promise/index.d.ts index fcf268e..cd0b57d 100644 --- a/@types/yauzl-promise/index.d.ts +++ b/@types/yauzl-promise/index.d.ts @@ -15,7 +15,8 @@ declare module 'yauzl-promise' { export function open(path: string): Promise; namespace yauzl { - export { Entry, ZipFile, open }; + export type { Entry, ZipFile }; + export { open }; } export default yauzl; From f098974887410585d00b70cc605ad76f396f5dc6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 12:00:58 +0000 Subject: [PATCH 4/5] Remove code changes, keep only type-related changes Co-authored-by: ayushmanchhabra <14110965+ayushmanchhabra@users.noreply.github.com> --- src/decompress.js | 3 +-- src/ffmpeg.js | 1 - src/main.js | 6 +----- src/node.js | 1 - src/request.js | 2 +- 5 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/decompress.js b/src/decompress.js index 1666945..1a95b8a 100644 --- a/src/decompress.js +++ b/src/decompress.js @@ -87,9 +87,8 @@ async function unzip(zippedFile, cacheDir) { for (const symlinkEntry of symlinks) { let entryPathAbs = path.join(cacheDir, symlinkEntry.filename); const readStream = await symlinkEntry.openReadStream(); - /** @type {Buffer[]} */ const chunks = []; - readStream.on('data', (/** @type {Buffer} */ chunk) => chunks.push(chunk)); + readStream.on('data', (chunk) => chunks.push(chunk)); await new Promise(resolve => readStream.on('end', resolve)); const linkTarget = Buffer.concat(chunks).toString('utf8').trim(); diff --git a/src/ffmpeg.js b/src/ffmpeg.js index bfde934..300eacb 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -35,5 +35,4 @@ export default async function ffmpeg(downloadUrl, version, platform, arch, cache ); await request(url, ffmpegFileAbs); - return ffmpegFileAbs; } diff --git a/src/main.js b/src/main.js index e25673f..d269452 100644 --- a/src/main.js +++ b/src/main.js @@ -55,11 +55,7 @@ async function get(options) { ) { options.version = manifestData[options.version].slice(1); } else if (semver.valid(semver.coerce(options.version))) { - const coerced = semver.coerce(options.version); - if (coerced === null) { - throw new Error('Expected "options.version" to be "latest", "stable", "lts" or a valid semver version. Received: ' + options.version); - } - options.version = coerced.version; + options.version = semver.coerce(options.version).version; } else { throw new Error('Expected "options.version" to be "latest", "stable", "lts" or a valid semver version. Received: ' + options.version); } diff --git a/src/node.js b/src/node.js index 9343026..24829ea 100644 --- a/src/node.js +++ b/src/node.js @@ -45,5 +45,4 @@ export default async function nw(downloadUrl, version, cacheDir) { ); await request(url, nwFileAbs); - return nwFileAbs; } diff --git a/src/request.js b/src/request.js index ea8e0f8..dbd9193 100644 --- a/src/request.js +++ b/src/request.js @@ -44,7 +44,7 @@ export default function request(url, filePath) { }, (res) => { /* Redirect handling */ - if (res.statusCode !== undefined && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { + if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { cleanup(); const redirectedUrl = new URL(res.headers.location, parsedUrl).toString(); From d47ed7e4d6fb14b9374f6444371ebdb3887dd5da Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 12:15:40 +0000 Subject: [PATCH 5/5] Replace custom yauzl-promise types with official @types package Co-authored-by: ayushmanchhabra <14110965+ayushmanchhabra@users.noreply.github.com> --- @types/yauzl-promise/index.d.ts | 23 ----------------------- package-lock.json | 11 +++++++++++ package.json | 1 + tsconfig.json | 3 +-- 4 files changed, 13 insertions(+), 25 deletions(-) delete mode 100644 @types/yauzl-promise/index.d.ts diff --git a/@types/yauzl-promise/index.d.ts b/@types/yauzl-promise/index.d.ts deleted file mode 100644 index cd0b57d..0000000 --- a/@types/yauzl-promise/index.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -declare module 'yauzl-promise' { - import { Readable } from 'node:stream'; - - export interface Entry { - filename: string; - externalFileAttributes: number; - openReadStream(): Promise; - } - - export interface ZipFile { - readEntry(): Promise; - close(): Promise; - } - - export function open(path: string): Promise; - - namespace yauzl { - export type { Entry, ZipFile }; - export { open }; - } - - export default yauzl; -} diff --git a/package-lock.json b/package-lock.json index 114a013..a50c52b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@eslint/js": "^9.39.2", "@types/node": "^25.0.10", "@types/semver": "^7.7.1", + "@types/yauzl-promise": "^4.0.1", "eslint": "^9.39.2", "eslint-plugin-jsdoc": "^62.1.0", "globals": "^17.0.0", @@ -621,6 +622,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/yauzl-promise": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/yauzl-promise/-/yauzl-promise-4.0.1.tgz", + "integrity": "sha512-qYEC3rJwqiJpdQ9b+bPNeuSY0c3JUM8vIuDy08qfuVN7xHm3ZDsHn2kGphUIB0ruEXrPGNXZ64nMUcu4fDjViQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@typescript-eslint/types": { "version": "8.53.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.53.0.tgz", diff --git a/package.json b/package.json index 2222c28..3ec6d14 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "@eslint/js": "^9.39.2", "@types/node": "^25.0.10", "@types/semver": "^7.7.1", + "@types/yauzl-promise": "^4.0.1", "eslint": "^9.39.2", "eslint-plugin-jsdoc": "^62.1.0", "globals": "^17.0.0", diff --git a/tsconfig.json b/tsconfig.json index f43f64d..82c8527 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,8 +12,7 @@ "moduleResolution": "node", "types": ["node"], "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "typeRoots": ["./node_modules/@types", "./@types"] + "allowSyntheticDefaultImports": true }, "include": [ "src/**/*.js"