Migrate from JavaScript to TypeScript with Vite + Vitest#160
Merged
Conversation
- Convert all JavaScript source files to TypeScript with proper typing - Replace Rollup build system with Vite for faster development - Replace tape test runner with Vitest for modern testing - Bundle TypeScript declarations into single file - Update demo to work with new build system - Maintain backward compatibility with existing API New build outputs: - dist/martinez.js (ES module) - dist/martinez.cjs (CommonJS) - dist/index.d.ts (bundled TypeScript declarations) Scripts: - npm run build: Build library - npm run test: Run tests with Vitest - npm run dev: Start dev server with demo - npm run typecheck: Type checking 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Remove ESLint, TypeScript ESLint plugins, and related dependencies - Add oxlint (Rust-based linter) for significantly faster performance - Configure oxlint with TypeScript support and reasonable rule set - Maintain code quality standards while improving build speed Performance improvement: - ESLint: ~2-3 seconds on 18 files - oxlint: 9ms on 18 files with 96 rules using 8 threads 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
TypeScript fixes: - Fix BBox type from interface to tuple [number, number, number, number] - Fix connectEdges function call signature (remove unused operation parameter) - Fix variable type conflicts in connect_edges.ts (separate tmpEvent and tmpPos) - Add proper null assertion operators for guaranteed non-null properties Build verification: - ✅ Build completes successfully: dist/martinez.js, dist/martinez.cjs, dist/index.d.ts - ✅ All 22 tests pass with Vitest - ✅ Library functions correctly - ✅ Main TypeScript errors resolved Remaining errors are only in debug utilities and test files, not in core library. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
✅ Successfully converted 7 additional test files: - compute_fields.test.js → compute_fields.test.ts (1 test) - featureTypes.test.js → featureTypes.test.ts (16 tests) - genericTestCases.test.js → genericTestCases.test.ts (27 tests) - index.test.js → index.test.ts (14 tests) - segment_intersection.test.js → segment_intersection.test.ts (11 tests) - sweep_event.test.js → sweep_event.test.ts (6 tests) - sweep_line.test.js → sweep_line.test.ts (1 test) 🎯 Test migration results: - **Before**: 22 tests passing (4 converted files) - **After**: 98 tests passing (11 converted files) - **Improvement**: 76 additional tests (+345% increase) 🔧 Key changes: - Converted complex nested tape test structures to proper Vitest describe/it blocks - Updated all assertions from tape to Vitest expect syntax - Added TypeScript support with proper type assertions - Added glob dependency for file system test discovery - Fixed import statements for modern package versions - Maintained all original test logic and fixtures All tests now run with Vitest and provide comprehensive coverage of the martinez polygon clipping library functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the Martinez polygon clipping library from JavaScript to TypeScript with modern tooling. The migration replaces Rollup/Buble/tape with Vite/Vitest while maintaining full API compatibility. All source files have been converted to TypeScript with proper type definitions, and a bundled TypeScript declarations file is now generated for distribution.
Key Changes:
- Complete TypeScript conversion of 18 source files with comprehensive type definitions
- Modern build system using Vite for faster development and building
- Vitest test framework replacing tape with 22 passing tests converted
- Simplified distribution with bundled TypeScript declarations
Reviewed changes
Copilot reviewed 39 out of 42 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| vite.config.ts | Configures Vite build with library mode, ES/CJS outputs, and TypeScript declaration bundling |
| vitest.config.ts | Configures Vitest test runner with Node environment and test file patterns |
| package.json | Updates build scripts, dependencies, and export paths for new tooling |
| src/types.ts | Defines core TypeScript types for geometric operations |
| src/*.ts | TypeScript conversions of all source modules with proper type annotations |
| test/*.test.ts | Converts test files from tape to Vitest format |
| oxlint.json | Configures oxlint for TypeScript and code quality checks |
| index.ts | Updates main entry point with TypeScript types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Owner
Author
|
closes #156 |
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
Key Changes
Build System
Output Files
dist/martinez.js- ES module builddist/martinez.cjs- CommonJS builddist/index.d.ts- Single bundled TypeScript declarations fileScripts
npm run build- Build library with Vitenpm run test- Run tests in watch modenpm run test:run- Run tests oncenpm run dev- Start dev server with demonpm run typecheck- Type checkingSource Code
Testing
Test Plan
npm run build✅npm run test:run✅ (22/22)npm run dev✅Breaking Changes
None - fully backward compatible API
🤖 Generated with Claude Code