Migrate to TypeScript and modernize build tooling#2
Open
codeKonami wants to merge 1 commit intomasterfrom
Open
Migrate to TypeScript and modernize build tooling#2codeKonami wants to merge 1 commit intomasterfrom
codeKonami wants to merge 1 commit intomasterfrom
Conversation
Replace legacy Babel 6 / Webpack 3 / Jest toolchain with a modern stack: - TypeScript (strict mode) for type safety and shipped .d.ts declarations - Vite 5 in library mode for ESM + CJS output (replaces Webpack + UglifyJS) - Vitest for unit testing (replaces Jest) Architecture improvements: - src/types.ts: HandRank/CompareResult enums, Card/Rank/Suit types - src/tables/: typed lookup tables (was src/arrays/) - src/evaluate/: pure evaluation functions (was src/utils/) - src/poker-hand.ts: PokerHand class with full type annotations - src/index.ts: clean public API entry point All 28 original tests ported and passing. Public API preserved. https://claude.ai/code/session_015nKLAdA1Gva9Yg4Rnfu2vR
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 modernizes the poker hand evaluator by migrating the codebase from JavaScript to TypeScript, replacing the webpack/babel build system with Vite, and updating the test framework from Jest to Vitest.
Key Changes
Language Migration: Converted all source files from JavaScript to TypeScript with full type safety
src/pokerhand.js→src/poker-hand.tswith proper type annotationssrc/evaluate/directory with typed implementationssrc/types.ts(HandRank and CompareResult enums, card types)Build System Modernization:
package.jsonto export both ESM and CommonJS formats with proper entry pointsTesting Framework: Migrated from Jest to Vitest
Code Organization:
src/tables/directory with TypeScript exportsevaluate/card.ts,evaluate/validate.ts,evaluate/rank.ts,evaluate/evaluate.tssrc/bench.tsas TypeScript replacement for the benchmark scriptAPI Improvements:
compareWith()now returns typedCompareResultenum instead of magic numbers (1, 2, 3)getRank()returns typedHandRankenum instead of string literalssrc/index.tsas clean public API exportHTML/Demo Updates:
index.htmlto use ES module importslangattribute, self-closing tags)CompareResultenum for result comparisonDevelopment Experience:
npm run devfor local development with Vitenpm run benchfor running benchmarks with tsxnpm run test:watchfor watch mode testingNotable Implementation Details
https://claude.ai/code/session_015nKLAdA1Gva9Yg4Rnfu2vR