Skip to content

Fix jsdoc types and use tsc for type safety checks#220

Merged
bcomnes merged 4 commits into
masterfrom
fix-types
May 17, 2026
Merged

Fix jsdoc types and use tsc for type safety checks#220
bcomnes merged 4 commits into
masterfrom
fix-types

Conversation

@bcomnes

@bcomnes bcomnes commented May 16, 2026

Copy link
Copy Markdown
Owner

Implements full type safety, fixes existing jsdoc types and generally cleans up esm support. Next release will be esm only, and I will not be releasing the cjs support that was never released.

Copilot AI review requested due to automatic review settings May 16, 2026 16:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces TypeScript-based type-checking for the JavaScript codebase (via JSDoc), adds local .d.ts shims for missing dependency types, and advances the package toward ESM-only support (including packaging/script updates and corresponding test updates).

Changes:

  • Added tsconfig.json / declaration.tsconfig.json and npm scripts to run tsc type-safety checks and generate declarations.
  • Added local type shims under types/ for dependencies lacking suitable declarations.
  • Updated runtime/library/CLI/test code with stricter JSDoc types and ESM-oriented imports; removed CJS compatibility artifacts/tests.

Reviewed changes

Copilot reviewed 34 out of 47 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
types/which/index.d.ts Adds local shim typings for which.
types/read-package-json-fast/index.d.ts Adds local shim typings for read-package-json-fast.
tsconfig.json Enables allowJs + checkJs type-checking and configures typeRoots.
declaration.tsconfig.json Adds declaration-only build config for emitting .d.ts files.
package.json Adds types, check:tsc, declaration build/clean scripts, and updates test coverage tooling; sets ESM-only main.
.gitignore Ignores generated declaration outputs under lib/.
.knip.jsonc Updates Knip entrypoints to reflect ESM-only structure.
scripts/make-slink.js Narrows caught error typing before reading err.code.
plans/add-full-jsdoc-type-checking.md Adds detailed plan/notes for the type-checking migration.
lib/spawn.js Adds JSDoc imports/types for spawn wrapper.
lib/spawn-win32.js Adds safer pid handling and JSDoc typing for Win32 spawn/kill.
lib/spawn-posix.js Adds safer pid handling and JSDoc typing for POSIX spawn/kill.
lib/run-tasks.js Tightens result typing, aggregate-output handling, and signal→exit-code mapping.
lib/run-task.js Tightens typing, stream handling, and pnpm detection logic (but contains a runtime ESM bug noted in comments).
lib/read-package-json.js Adds typed return shape for package.json reading helper.
lib/npm-run-all-error.js Makes error message robust to task vs name presence.
lib/match-tasks.js Adds JSDoc typedefs and narrows colon/slash conversion typing.
lib/index.js Adds public API typedefs and refactors promise chain to async flow with stronger typing.
lib/create-prefix-transform-stream.js Adds JSDoc types for state and transform callback.
lib/create-header.js Types packageInfo nullable and avoids missing scripts lookups.
lib/cjs.cjs Removes the CommonJS wrapper entry (ESM-only move).
bin/run-s/main.js Switches to internal ESM import and narrows error handling/types.
bin/run-s/help.js Adds stream typing and returns Promise<null>.
bin/run-p/main.js Switches to internal ESM import and narrows error handling/types.
bin/run-p/help.js Adds stream typing and returns Promise<null>.
bin/npm-run-all/main.js Switches to internal ESM import and narrows error handling/types.
bin/npm-run-all/help.js Adds stream typing and returns Promise<null>.
bin/common/version.js Adds stream typing and returns Promise<null>.
bin/common/parse-cli-args.js Adds precise JSDoc typedefs and improves argument parsing guards.
bin/common/bootstrap.js Adds JSDoc signature for bootstrap function.
test/yarn.js Adds null-guard for cp.stderr when piping.
test/sequential.js Updates imports to local ESM entry and adds stronger assertions/types.
test/print-name.js Updates imports and aligns createHeader call signature.
test/print-label.js Updates imports to local ESM entry.
test/pattern.js Updates imports and tightens assertions/types, including undefined vs null.
test/parallel.js Updates imports to local ESM entry and adds stronger assertions/types.
test/package-config.js Fixes npm major parsing/type safety.
test/lib/util.cjs Narrows caught errors before checking code.
test/lib/spawn-with-kill.cjs Adds JSDoc typing for helper.
test/lib/buffer-stream.cjs Adds @override tag for _write.
test/fail.js Tightens JSDoc types and narrows caught errors before reading .code.
test/config.js Updates imports to local ESM entry.
test/common.js Updates imports to local ESM entry and tightens assertions/types.
test/argument-placeholders.js Updates imports and fixes typing for strictEqual.
test/aggregate-output.js Updates imports and tightens stdout typing/init.
test/compatibility.mjs Removes ESM import-map compatibility test.
test/compatibility.cjs Removes CJS compatibility tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/run-task.js
Comment thread lib/run-task.js Outdated
Comment thread package.json
@bcomnes bcomnes force-pushed the fix-types branch 2 times, most recently from 68c7174 to 730a550 Compare May 16, 2026 16:20
@bcomnes bcomnes requested a review from Copilot May 16, 2026 16:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 51 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

lib/index.js:216

  • The public JSDoc for npmRunAll() declares patternOrPatterns as string|string[], but the implementation (via toArray()) explicitly accepts null|undefined and tests rely on nodeApi(null) as a supported way to do nothing. This mismatch will leak into generated declarations / type checking; update the @param type (and, if intended, document the null behavior) so the published types match runtime behavior.

Comment thread test/aggregate-output.js Outdated
Comment thread lib/match-tasks.js Outdated
Comment thread lib/run-task.js Outdated
@bcomnes

bcomnes commented May 16, 2026

Copy link
Copy Markdown
Owner Author

Need to make sure the npm tarball has everything it needs in it. Also need to switch to the files glob array in package.json

@bcomnes

bcomnes commented May 16, 2026

Copy link
Copy Markdown
Owner Author

I will cut the next major release after this lands.

@bcomnes bcomnes requested a review from Copilot May 16, 2026 18:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 51 changed files in this pull request and generated 1 comment.

Comment thread lib/run-task.js
@bcomnes bcomnes force-pushed the fix-types branch 2 times, most recently from e2803a4 to 8542825 Compare May 17, 2026 17:46
@socket-security

socket-security Bot commented May 17, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​memorystream@​0.3.4891007280100
Added@​types/​picomatch@​3.0.21001007484100
Added@​voxpelli/​tsconfig@​16.2.17410010088100
Added@​types/​cross-spawn@​6.0.61001007880100
Added@​types/​shell-quote@​1.7.51001008780100
Added@​types/​node@​22.19.191001008196100

View full report

@bcomnes

bcomnes commented May 17, 2026

Copy link
Copy Markdown
Owner Author

Ok looking good to merge.

@bcomnes bcomnes merged commit d93ab4e into master May 17, 2026
15 checks passed
@bcomnes bcomnes deleted the fix-types branch May 17, 2026 20:08
@bcomnes bcomnes mentioned this pull request May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants