Migrate codebase from JavaScript to TypeScript#8
Merged
Conversation
- Rewrote core ISIN generation logic in TypeScript (src/generate-isin.ts),
replacing the old index.js CommonJS module with typed ES module exports
- Moved country codes from country-codes.json into a typed TS fixture
(src/fixtures/country-codes.ts)
- Added optional countryCode parameter to generateIsin() so callers can
pin the country code (e.g. generateIsin("US"))
- Fixed four bugs in the migrated code: CUSIP was generated once at module
load (now per-call), orphaned dead statement removed, error was created
but never thrown, and calculateValues/calculateCheckDigit were typed as
string[] instead of number[]
- Added Jest test suite with deterministic assertions using a mocked CUSIP,
covering correct check digit calculation for known ISINs (US0378331005,
GB0378331002), case-insensitive country codes, per-call CUSIP generation,
and a performance benchmark via kelonio
- Added Stryker mutation testing config; generate-isin.ts achieves 87.8%
mutation score
- Added GitHub Actions CI workflow running build, coverage, and mutation
tests on push/PR to master
- Added Dependabot config for daily npm dependency updates
- Added Husky pre-push hook with interactive merge-main and run-tests prompts
- Added examples/ directory with a standalone TypeScript usage example
- Added tsconfig.json, jest.config.js, stryker.conf.json, .nvmrc, and
release/prepush shell scripts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rewrote README to reflect TypeScript migration: updated usage examples to show the optional countryCode parameter, fixed the broken ES6 import, replaced ES5/ES6 sections with CommonJS/ESM, and added an API reference section - Added CLAUDE.md with development commands, codebase architecture, and guidance for future Claude Code sessions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
This PR rewrites the entire codebase from JavaScript to TypeScript, adds a comprehensive test suite, fixes several bugs found during the migration, and sets up CI/CD tooling.
Changes
TypeScript migration
index.js(CommonJS) with typed ES modules undersrc/src/generate-isin.tswith proper type annotationscountry-codes.jsoninto a typed fixture atsrc/fixtures/country-codes.tssrc/index.tsadded as the package entry pointtsconfig.jsonadded to configure compilation tobuild/New features
generateIsin()now accepts an optionalcountryCodeparameter, allowing callers to pin the country (e.g.generateIsin("US")). Country code is treated as case-insensitive.Bug fixes found during migration
generateCusip()insidegenerateIsin()so each call produces a fresh value.countryCodes[Math.random() * ...]expression was computed but its result discarded. Removed.new Error(...)was created but not thrown. Fixed tothrow new Error(...).calculateValueswas typed as returningstring[]but pushed numbers;calculateCheckDigitacceptedstring[]and used redundantparseIntcalls. Corrected tonumber[].Testing
src/__tests__/generate-isin.spec.ts) using a mocked CUSIP for deterministic assertionsUS0378331005,GB0378331002) to verify correct check digit calculation end-to-endkelonio(~0.03ms per call)generate-isin.tsachieves 87.8% mutation scoreCI/CD & tooling
.github/workflows/tests.yml) runs build, coverage, and mutation tests on push/PR tomastermasterand run tests before pushingrelease.shandprepush.shscripts added.nvmrcadded to pin Node versionexamples/directory added with a standalone TypeScript usage exampleTest plan
npm test— all 9 tests passnpm run test:coverage— full coverage run passesnpm run test:mutation— 87.8% mutation score on core logicnpm run build— TypeScript compiles cleanly tobuild/🤖 Generated with Claude Code