Modernize to TypeScript and current Node LTS#579
Merged
Conversation
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
9268dc4 to
ca642d6
Compare
Owner
Author
|
headshot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Modernizes this tiny library along a few axes — same public API, no behavior change:
src/index.js→src/index.ts; tests too.tsupnow emits.d.tsand atypescondition is added topackage.json#exports, so consumers get types. TypeScript was already a devDep but wasn't doing anything.ArrayBuffer/Float32Array/Int32Arrayare hoisted to module scope — they were being reallocated on everytoNaN/fromNaNcall. Single-threaded JS makes this safe (these functions are synchronous and atomic).nanbox) instead of leaving it anonymous.node --experimental-strip-types --test). Notsx/ts-node/extra test runner.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-versionbumped.tsc --noEmitso type errors fail the build.@masterto@v2(pinned, with current input names)..npmignoreentries (.babelrc,nyc.config.js, removedREADME.mdwhich npm needs).Test plan
npm run build— emitsdist/index.{js,cjs,d.ts,d.cts}npx tsc --noEmit— cleannpm test— all 5 tests pass under--experimental-strip-typesimport/requireboth round-trip a codepoint throughnanboxandtoNaN/fromNaNnpx eslint— cleanhttps://claude.ai/code/session_01RyCEnf6V2vWGWRsRZQrjFP
Generated by Claude Code