Skip to content

Commit 70e76c7

Browse files
committed
fix: resolve all lint and type errors, enable strict TypeScript
- Convert non-const enums to `as const` objects in src/types.ts - Re-enable erasableSyntaxOnly: true in tsconfig.base.json - Remove strict: false override from tsconfig.check.json - Fix 91 type errors across 24 source files - Fix 401 type errors across 43 test files - Fix 17 oxlint errors (no-import-assign, no-new-array) in test files - Fix pico-pack.d.ts glob type reference
1 parent 0cf07dd commit 70e76c7

101 files changed

Lines changed: 867 additions & 782 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.config/tsconfig.base.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"composite": false,
66
"declaration": false,
77
"declarationMap": false,
8-
"erasableSyntaxOnly": false,
8+
"erasableSyntaxOnly": true,
99
"esModuleInterop": true,
1010
"exactOptionalPropertyTypes": true,
1111
"forceConsistentCasingInFileNames": true,

.config/tsconfig.check.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
"noEmit": true,
55
"rootDir": "..",
66
"types": ["node", "vitest"],
7-
"skipLibCheck": true,
8-
"strict": false,
9-
"noImplicitAny": false
7+
"skipLibCheck": true
108
},
119
"include": ["../src/**/*.ts", "../test/**/*.ts", "../test/**/*.mts"],
1210
"exclude": ["../node_modules", "../dist/**/*"]

src/archives.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let _path: typeof import('node:path') | undefined
4242
/*@__NO_SIDE_EFFECTS__*/
4343
function getPath() {
4444
if (_path === undefined) {
45-
_path = /*@__PURE__*/ require('path')
45+
_path = /*@__PURE__*/ require('node:path')
4646
}
4747
return _path as typeof import('node:path')
4848
}
@@ -57,15 +57,15 @@ export type ArchiveFormat = 'tar' | 'tar.gz' | 'tgz' | 'zip'
5757
*/
5858
export interface ExtractOptions {
5959
/** Suppress log messages */
60-
quiet?: boolean
60+
quiet?: boolean | undefined
6161
/** Strip leading path components (like tar --strip-components) */
62-
strip?: number
62+
strip?: number | undefined
6363
/** Maximum number of entries to extract (default: 100,000) */
64-
maxEntries?: number
64+
maxEntries?: number | undefined
6565
/** Maximum size of a single extracted file in bytes (default: 100MB) */
66-
maxFileSize?: number
66+
maxFileSize?: number | undefined
6767
/** Maximum total extracted size in bytes (default: 1GB) */
68-
maxTotalSize?: number
68+
maxTotalSize?: number | undefined
6969
}
7070

7171
/**

src/bin.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function getFs() {
3434
if (_fs === undefined) {
3535
// Use non-'node:' prefixed require to avoid Webpack errors.
3636

37-
_fs = /*@__PURE__*/ require('fs')
37+
_fs = /*@__PURE__*/ require('node:fs')
3838
}
3939
return _fs as typeof import('node:fs')
4040
}
@@ -52,7 +52,7 @@ function getPath() {
5252
if (_path === undefined) {
5353
// Use non-'node:' prefixed require to avoid Webpack errors.
5454

55-
_path = /*@__PURE__*/ require('path')
55+
_path = /*@__PURE__*/ require('node:path')
5656
}
5757
return _path as typeof import('node:path')
5858
}
@@ -806,7 +806,10 @@ export async function whichReal(
806806
// Depending on options `whichModule` may throw if `binName` is not found.
807807
// With nothrow: true, it returns null when `binName` is not found.
808808
/* c8 ignore next - External which call */
809-
const result = await whichModule(binName, opts)
809+
const result = await whichModule(
810+
binName,
811+
opts as import('./external/which').WhichOptions,
812+
)
810813

811814
// When 'all: true' is specified, ensure we always return an array.
812815
if (opts?.all) {

src/constants/agents.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export const NPM_REAL_EXEC_PATH = /*@__PURE__*/ (() => {
3434
if (!_npmBinPath) {
3535
return undefined
3636
}
37-
const { existsSync } = /*@__PURE__*/ require('fs')
38-
const path = /*@__PURE__*/ require('path')
37+
const { existsSync } = /*@__PURE__*/ require('node:fs')
38+
const path = /*@__PURE__*/ require('node:path')
3939
// npm bin is typically at: /path/to/node/bin/npm
4040
// cli.js is at: /path/to/node/lib/node_modules/npm/lib/cli.js
4141
// /path/to/node/bin

src/constants/package-default-node-range.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import { maintainedNodeVersions } from './maintained-node-versions'
66
import * as semver from '../external/semver.js'
77

88
/* c8 ignore next - External semver call */
9-
const packageDefaultNodeRange = `>=${semver.parse(maintainedNodeVersions.last).major}`
9+
const packageDefaultNodeRange = `>=${semver.parse(maintainedNodeVersions.last)!.major}`
1010

1111
export { packageDefaultNodeRange }

src/constants/platform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function getOs() {
1212
if (_os === undefined) {
1313
// Use non-'node:' prefixed require to avoid Webpack errors.
1414

15-
_os = /*@__PURE__*/ require('os')
15+
_os = /*@__PURE__*/ require('node:os')
1616
}
1717
return _os as typeof import('node:os')
1818
}

src/cover/code.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function getFs() {
2626
if (_fs === undefined) {
2727
// Use non-'node:' prefixed require to avoid Webpack errors.
2828

29-
_fs = /*@__PURE__*/ require('fs')
29+
_fs = /*@__PURE__*/ require('node:fs')
3030
}
3131
return _fs as typeof import('node:fs')
3232
}
@@ -39,7 +39,7 @@ function getPath() {
3939
if (_path === undefined) {
4040
// Use non-'node:' prefixed require to avoid Webpack errors.
4141

42-
_path = /*@__PURE__*/ require('path')
42+
_path = /*@__PURE__*/ require('node:path')
4343
}
4444
return _path as typeof import('node:path')
4545
}

src/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function getUtil() {
7474
if (_util === undefined) {
7575
// Use non-'node:' prefixed require to avoid Webpack errors.
7676

77-
_util = /*@__PURE__*/ require('util')
77+
_util = /*@__PURE__*/ require('node:util')
7878
}
7979
return _util as typeof import('node:util')
8080
}

src/dlx/binary.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function getCrypto() {
2727
if (_crypto === undefined) {
2828
// Use non-'node:' prefixed require to avoid Webpack errors.
2929

30-
_crypto = /*@__PURE__*/ require('crypto')
30+
_crypto = /*@__PURE__*/ require('node:crypto')
3131
}
3232
return _crypto as typeof import('node:crypto')
3333
}
@@ -44,7 +44,7 @@ function getFs() {
4444
if (_fs === undefined) {
4545
// Use non-'node:' prefixed require to avoid Webpack errors.
4646

47-
_fs = /*@__PURE__*/ require('fs')
47+
_fs = /*@__PURE__*/ require('node:fs')
4848
}
4949
return _fs as typeof import('node:fs')
5050
}
@@ -62,7 +62,7 @@ function getPath() {
6262
if (_path === undefined) {
6363
// Use non-'node:' prefixed require to avoid Webpack errors.
6464

65-
_path = /*@__PURE__*/ require('path')
65+
_path = /*@__PURE__*/ require('node:path')
6666
}
6767
return _path as typeof import('node:path')
6868
}

0 commit comments

Comments
 (0)