This guide covers working with the TypeScript codebase for arc.js.
npm install # Install dependencies
npm run build # Build ESM output
npm test # Run TypeScript testssrc/
├── index.ts # Main entry point
├── coord.ts # Coordinate class
├── arc.ts # Arc class
├── great-circle.ts # Great circle calculations
├── line-string.ts # Internal geometry helper
├── utils.ts # Utility functions
└── types.ts # TypeScript type definitions
test/
└── *.test.ts # Jest TypeScript tests
# Run TypeScript tests (fast, for development)
npm test
# Watch mode for development
npm run test:watch
# Coverage report
npm run test:coveragenpm run buildThis generates dist/ — ESM output with .d.ts declaration files.
- Create PR: Submit changes via pull request
- Code review: Wait for maintainer approval
- Merge: Maintainer merges approved changes
- Publishing: Maintainer handles npm publishing
- Tests pass:
npm test - Build succeeds:
npm run build - Version updated: Update
package.jsonversion - Changelog updated: Document changes
- PR approved: All changes reviewed and merged
npm publish # prepublishOnly runs npm run build automaticallydist/folder (compiled ESM JS + TypeScript definitions)src/folder (TypeScript source files)README.md,LICENSE.md,CHANGELOG.md
- Source: Modern TypeScript with strict settings
- Output: ES2022, ESM only
- Declarations: Full
.d.tsgeneration for consumers
- Add interfaces/types to
src/types.ts - Export public types from
src/index.ts - Import types with
import type { ... } - Add tests in relevant
test/*.test.tsfiles includingtypescript.test.ts
// ES Modules (Node.js or bundler)
import { GreatCircle } from 'arc';To inspect all test routes as great circle arcs on a map:
npm run build # dist/ must exist
node scripts/dump-fixtures.mjs | pbcopy # macOS: copy to clipboardThen, paste the geojson output into a visualization tool to visually verify routes, such as geojson.io.
Note: route coordinates in the script are manually updated to keep in sync with test/fixtures/routes.ts.
# Clean build artifacts
npm run clean
# Development with auto-rebuild
npm run test:watch
# Coverage report
npm run test:coverage
# Check types only (no tests)
npx tsc --noEmit