Skip to content

Modernize to TypeScript and current Node LTS#579

Merged
philihp merged 2 commits into
mainfrom
claude/modernize-codebase-jVrWg
May 11, 2026
Merged

Modernize to TypeScript and current Node LTS#579
philihp merged 2 commits into
mainfrom
claude/modernize-codebase-jVrWg

Conversation

@philihp

@philihp philihp commented May 11, 2026

Copy link
Copy Markdown
Owner

Summary

Modernizes this tiny library along a few axes — same public API, no behavior change:

  • TypeScript source. src/index.jssrc/index.ts; tests too. tsup now emits .d.ts and a types condition is added to package.json#exports, so consumers get types. TypeScript was already a devDep but wasn't doing anything.
  • Stop reallocating on every call. The ArrayBuffer/Float32Array/Int32Array are hoisted to module scope — they were being reallocated on every toNaN/fromNaN call. Single-threaded JS makes this safe (these functions are synchronous and atomic).
  • Name the default export (nanbox) instead of leaving it anonymous.
  • Tests use Node's built-in TS stripping (node --experimental-strip-types --test). No tsx/ts-node/extra test runner.
  • Node baseline. engines.node>=22.6 (required for type stripping). CI drops EOL Node 18 and near-EOL Node 20; runs on 22.x and 24.x. .node-version bumped.
  • CI also runs tsc --noEmit so type errors fail the build.
  • Coveralls action bumped from @master to @v2 (pinned, with current input names).
  • Cleaned up stale .npmignore entries (.babelrc, nyc.config.js, removed README.md which npm needs).

Test plan

  • npm run build — emits dist/index.{js,cjs,d.ts,d.cts}
  • npx tsc --noEmit — clean
  • npm test — all 5 tests pass under --experimental-strip-types
  • Smoke-test the built artifacts: ESM and CJS import/require both round-trip a codepoint through nanbox and toNaN/fromNaN
  • npx eslint — clean
  • CI matrix (22.x, 24.x) passes on GitHub Actions

https://claude.ai/code/session_01RyCEnf6V2vWGWRsRZQrjFP


Generated by Claude Code

claude added 2 commits May 11, 2026 17:26
Pure file rename; no content changes. The follow-up commit converts
the contents to TypeScript.
- Type-annotate source and tests; ship .d.ts via tsup dts emit
- Hoist ArrayBuffer/views to module scope (was reallocated per call)
- Name the default export
- Run tests with node --experimental-strip-types against .ts source
- Add tsconfig.json and a typecheck script
- Add types condition to package.json exports
- Bump engines to >=22.6 (required for type stripping)
- Drop EOL Node 18 and near-EOL Node 20 from CI; test on 22.x and 24.x
- Bump .node-version to 22.12.0; clean up stale .npmignore entries
@philihp philihp force-pushed the claude/modernize-codebase-jVrWg branch from 9268dc4 to ca642d6 Compare May 11, 2026 17:28
@philihp

philihp commented May 11, 2026

Copy link
Copy Markdown
Owner Author

headshot

@philihp philihp marked this pull request as ready for review May 11, 2026 17:33
@philihp philihp merged commit 0bfd49c into main May 11, 2026
5 checks passed
@philihp philihp deleted the claude/modernize-codebase-jVrWg branch May 11, 2026 17:34
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