Skip to content

Migrate Specberus to TypeScript and improve API surface#2134

Merged
kfranqueiro merged 11 commits into
mainfrom
typescript
Jun 29, 2026
Merged

Migrate Specberus to TypeScript and improve API surface#2134
kfranqueiro merged 11 commits into
mainfrom
typescript

Conversation

@kfranqueiro

@kfranqueiro kfranqueiro commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Reminder: This should be rebase-merged to keep individual commit messages for the release notes

This PR is to merge the typescript branch, which has received a number of already-reviewed PRs:

The major points:

  • The entire codebase has been migrated to TypeScript
  • The tests no longer depend on mocha and chai, instead using Node's node:test module
  • The API surface has been converted to promise-based (away from callback-based) wherever feasible
  • The API surface has been limited to only the entry-point APIs; other APIs have been made private and/or split out from the main module (which is now specberus.js, changed from validator.js)

In addition to removing Node v20 support within this repo, this branch performs major-version upgrades of dependencies which have also removed v20 support in their latest versions. We had intentionally held these back until this upgrade across the codebase.

Along the way I have checked that existing tests continue to operate as expected and continue to pass. I have also performed tests consuming specberus@12.3.1 and specberus-13.0.0.tgz (via npm pack) to confirm identical output for equivalent input.

I've also tested consuming this in the context of the following projects that consume specberus:

  • echidna, via intellisense and npm test
  • spec-prod, via intellisense and npm run typecheck, and ensuring the profiles export from lib/util contains the same information in v12 and v13

@kfranqueiro kfranqueiro requested a review from deniak June 29, 2026 14:41
kfranqueiro and others added 11 commits June 29, 2026 17:08
Co-authored-by: Denis Ah-Kang <1696128+deniak@users.noreply.github.com>
…ises (#2106)

Additional improvements:

- Switch all fs function usage in validator.ts to fs/promises
- Remove Specberus#clearCache
- Add Specberus#load which performs common logic of branching to loadFile/loadURL/loadSource (which are now also private)
- Mark more class members as private where feasible
- Replace sr.throw calls within rules with actual throw statements, centralizing all throw method calls within validator.ts, ensuring that rejection occurs in response to unexpected errors
- Remove start-all/end-all events; use promise APIs in app, api, and tests
- Remove doasync (and reorganize some variables for better type safety)
- Remove public meta property; rely on resolved promise value instead
- Make Specberus emit events directly; thoroughly define event types
- Remove unused parameter from extractHeaders
- lib/util: Remove unused parameter names; update JSDoc
- Fire 'done' event even if an exception occurs
- app.ts: Consistently report misc. (non-'exception') errors
- Add new/missing test cases
- Update docs (including some long-overdue updates)

---------

Co-authored-by: Denis Ah-Kang <1696128+deniak@users.noreply.github.com>
Co-authored-by: Denis Ah-Kang <1696128+deniak@users.noreply.github.com>
@kfranqueiro kfranqueiro merged commit 81a24ad into main Jun 29, 2026
8 checks passed
@kfranqueiro kfranqueiro deleted the typescript branch June 29, 2026 21:44
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