Skip to content

Commit 9e4c74e

Browse files
chore(ci): fix types (#18)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 93b5361 commit 9e4c74e

9 files changed

Lines changed: 61 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
- name: Check for type errors
4242
run: npm run type
4343

44+
- name: Check for typing errors
45+
run: npm run type
46+
4447
- name: Run tests with coverage
4548
id: coverage
4649
shell: bash

package-lock.json

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
},
5454
"devDependencies": {
5555
"@eslint/js": "^9.39.2",
56+
"@types/node": "^25.0.10",
57+
"@types/semver": "^7.7.1",
58+
"@types/yauzl-promise": "^4.0.1",
5659
"eslint": "^9.39.2",
5760
"eslint-plugin-jsdoc": "^62.1.0",
5861
"globals": "^17.0.0",

src/decompress.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ async function unzip(zippedFile, cacheDir) {
8787
for (const symlinkEntry of symlinks) {
8888
let entryPathAbs = path.join(cacheDir, symlinkEntry.filename);
8989
const readStream = await symlinkEntry.openReadStream();
90+
/** @type {Buffer[]} */
9091
const chunks = [];
9192
readStream.on('data', (chunk) => chunks.push(chunk));
9293
await new Promise(resolve => readStream.on('end', resolve));

src/ffmpeg.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ export default async function ffmpeg(downloadUrl, version, platform, arch, cache
3535
);
3636

3737
await request(url, ffmpegFileAbs);
38+
return ffmpegFileAbs;
3839
}

src/main.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ async function get(options) {
5454
|| options.version === "lts"
5555
) {
5656
options.version = manifestData[options.version].slice(1);
57-
} else if (semver.valid(semver.coerce(options.version))) {
58-
options.version = semver.coerce(options.version).version;
5957
} else {
60-
throw new Error('Expected "options.version" to be "latest", "stable", "lts" or a valid semver version. Received: ' + options.version);
58+
const coerced = semver.coerce(options.version);
59+
if (coerced && semver.valid(coerced)) {
60+
options.version = coerced.version;
61+
} else {
62+
throw new Error('Expected "options.version" to be "latest", "stable", "lts" or a valid semver version. Received: ' + options.version);
63+
}
6164
}
6265

6366
if (options.flavor !== "normal" && options.flavor !== "sdk") {

src/node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ export default async function nw(downloadUrl, version, cacheDir) {
4545
);
4646

4747
await request(url, nwFileAbs);
48+
return nwFileAbs;
4849
}

src/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default function request(url, filePath) {
4444
},
4545
(res) => {
4646
/* Redirect handling */
47-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
47+
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
4848
cleanup();
4949

5050
const redirectedUrl = new URL(res.headers.location, parsedUrl).toString();

tsconfig.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
"declaration": true,
66
"emitDeclarationOnly": true,
77
"outDir": "types",
8-
"strict": true
8+
"strict": true,
9+
"target": "ES2020",
10+
"lib": ["ES2020"],
11+
"module": "ESNext",
12+
"moduleResolution": "node",
13+
"types": ["node"],
14+
"esModuleInterop": true,
15+
"allowSyntheticDefaultImports": true
916
},
1017
"include": [
1118
"src/**/*.js"

0 commit comments

Comments
 (0)