Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 17, 2025

TypeScript Migration Complete - node-dijkstra v3.0.0

Successfully Completed ✅

  • Set up TypeScript tooling and configuration
  • Update package.json for TypeScript support and v3.0.0
  • Convert core modules to TypeScript with proper type definitions:
    • PriorityQueue.js → PriorityQueue.ts with full type safety
    • validateDeep.js → validateDeep.ts
    • toDeepMap.js → toDeepMap.ts
    • removeDeepFromMap.js → removeDeepFromMap.ts
    • Graph.js → Graph.ts (main entry point) with method overloads
  • Convert test files to TypeScript (56 tests passing)
  • Update build system for TypeScript compilation
  • Update ESLint configuration for TypeScript
  • Add comprehensive type declaration files (.d.ts)
  • Update README.md for v3.0.0 and TypeScript usage
  • Verify everything works and all tests pass
  • Update repository to modern patterns (ES modules, latest Node.js support)
  • Remove legacy JavaScript files and Gulp build system

Latest Improvements ✅

  • Removed JSDoc comments from all source files - types provide the documentation
  • Improved type system with better semantic types (NodeKey, EdgeWeight, GraphNode)
  • Simplified README - focused on types, removed verbose documentation and old version references
  • Removed deprecated methods (addVertex, shortestPath) for cleaner API
  • Updated CI configuration to use latest GitHub Actions (v4)

ESLint Strict Configuration ✅

  • Removed all ESLint rule exceptions as requested
  • Using vanilla ESLint:recommended + TypeScript strict rules
  • No custom overrides in source code rules
  • Proper TypeScript typing without method overloads that trigger ESLint errors
  • Test-only exceptions for necessary any usage when testing private members

Type System Consolidation ✅

  • Moved GraphNode type to Graph.ts for centralized type definitions
  • Updated all imports to use types from Graph.ts instead of individual modules
  • Consistent type usage across all modules using NodeKey, EdgeWeight, GraphNode
  • Improved type clarity with centralized type definitions

Interface Documentation ✅

  • Added documentation comments for all PathOptions properties:
    • trim: Exclude the origin and destination nodes from the result
    • reverse: Return the path in reversed order, from goal to start
    • cost: Return an object with path and cost instead of just the path
    • avoid: Array of nodes to be avoided when finding the path
  • Better developer experience with inline documentation visible in IDEs

Repository Cleanup ✅

  • Merged master branch (v2.5.1) incorporating latest changes including release workflow
  • Resolved conflicts while maintaining v3.0.0 improvements
  • Removed .map files from repository - these are build artifacts (source maps) that don't belong in version control
  • Updated .gitignore to exclude *.map files going forward

CI/CD Configuration ✅

  • Updated Node.js test matrix to test against:
    • Node.js 20.x (oldest LTS supported)
    • Node.js latest (bleeding edge)
  • Modern CI pipeline aligned with current Node.js support strategy

Current ESLint Rules

  • eslint:recommended (vanilla)
  • @typescript-eslint/no-unused-vars
  • @typescript-eslint/no-explicit-any
  • @typescript-eslint/no-var-requires

All 56 tests passing with strict TypeScript rules, consolidated type system, documented interfaces, clean repository, and modern CI/CD pipeline!


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Rewrite the codebase in TypeScript: - Follow all community best practices - Ensure everything works - Update the overall repository to the latest industry patterns - Update the readme as needed - Release it as v3.0.0 Rewrite codebase in TypeScript for v3.0.0 - Modern patterns and full type safety Sep 17, 2025
Copilot finished work on behalf of albertorestifo September 17, 2025 08:07
@albertorestifo
Copy link
Owner

@copilot I think we can remove the JSDoc comments from the code now that we have types.

Please rewiew all types and singature of the functions, we should take advantage of typescript to build a solid type system for the graph sturcture.

Simplify the documentation to also simply reference the types, there is no need to be so verbose anymore now that it's strictly type. Do not mention older releases of this package anymore in the readme, there is no need really.

Add a pipeline to make sure it works with node latest as well.

Copy link
Contributor Author

Copilot AI commented Sep 17, 2025

@copilot I think we can remove the JSDoc comments from the code now that we have types.

Please rewiew all types and singature of the functions, we should take advantage of typescript to build a sol...

Done! I've implemented all your requested changes:

Removed JSDoc comments - TypeScript types now provide the documentation
Improved type system - Added semantic types like NodeKey, EdgeWeight, GraphNode for better developer experience
Simplified README - Focused on types, removed verbose documentation and old version references
Added Node.js latest to CI pipeline - now tests against 16.x, 18.x, 20.x, and latest

Additional improvements:

  • Removed deprecated methods (addVertex, shortestPath) for a cleaner API
  • Updated GitHub Actions to v4
  • Enhanced type safety with better semantic naming

All 56 tests passing with full type safety! The codebase is now much cleaner and leverages TypeScript's type system effectively.

Commit: bebaa8b

Copilot AI changed the title Rewrite codebase in TypeScript for v3.0.0 - Modern patterns and full type safety Rewrite codebase in TypeScript for v3.0.0 - Clean types without JSDoc Sep 17, 2025
.eslintrc Outdated
],
"rules": {
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"no-dupe-class-members": "off"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Remove this exceptions to the rules. We want vanilla eslint:recommented and typescript strict rules.

After changing this, make sure everything passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all ESLint rule exceptions as requested. Now using vanilla eslint:recommended plus strict TypeScript rules:

  • @typescript-eslint/no-unused-vars
  • @typescript-eslint/no-explicit-any
  • @typescript-eslint/no-var-requires

Had to refactor method overloads to avoid no-dupe-class-members errors while maintaining type safety. All 56 tests passing with strict rules.

Commit: cdacdfa

Copilot AI changed the title Rewrite codebase in TypeScript for v3.0.0 - Clean types without JSDoc Rewrite codebase in TypeScript for v3.0.0 - Clean types with strict ESLint rules Sep 17, 2025
Copilot finished work on behalf of albertorestifo September 17, 2025 08:56
src/toDeepMap.ts Outdated
return !isNaN(cost) && cost > 0;
}

export type GraphNode = number | Map<string | number, GraphNode>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this should re-use types defined in Graph.ts and be moved there.

Also the types in the other palces might need to use this type for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved GraphNode type definition to Graph.ts and updated all modules to import types from the centralized location. Now all type definitions (NodeKey, EdgeWeight, GraphNode) are consistently managed in Graph.ts for better clarity and maintainability.

Updated imports in:

  • toDeepMap.ts
  • validateDeep.ts
  • removeDeepFromMap.ts

All 56 tests passing with the consolidated type system.

Commit: 4a7ad91

…mports for better type clarity

Co-authored-by: albertorestifo <[email protected]>
Copilot AI changed the title Rewrite codebase in TypeScript for v3.0.0 - Clean types with strict ESLint rules Rewrite codebase in TypeScript for v3.0.0 - Clean types with documented interfaces and strict ESLint rules Sep 17, 2025
Copilot finished work on behalf of albertorestifo September 17, 2025 09:36
@albertorestifo
Copy link
Owner

@copilot Solve the conflicts with master, and remove the .map JS files from the repo, why are they even needed?

Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot Solve the conflicts with master, and remove the .map JS files from the repo, why are they even needed?

Resolved conflicts with master by keeping v3.0.0 changes (package.json and README.md). Merged in the release workflow and CHANGELOG from master.

Removed all .map files (JavaScript and TypeScript source maps) from the repository. These files were generated by the TypeScript compiler during build (sourceMap: true and declarationMap: true in tsconfig.json). They're build artifacts that don't need to be in version control since they're regenerated each build.

Added *.map to .gitignore to prevent them from being committed in the future.

All 56 tests passing after the merge.

Commits: 4be5a75 (merge) + d47518d (cleanup)

Copilot finished work on behalf of albertorestifo November 5, 2025 08:36
@albertorestifo
Copy link
Owner

@copilot In the CI, test the following (oldest LTS supported releases + latest): 20, 26, latest

Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot In the CI, test the following (oldest LTS supported releases + latest): 20, 26, latest

Updated CI configuration to test Node.js 20.x (oldest LTS supported), 26.x (current LTS), and latest. Removed testing for Node.js 16.x and 18.x.

All 56 tests passing.

Commit: 25421df

Copilot finished work on behalf of albertorestifo November 5, 2025 08:52
@albertorestifo
Copy link
Owner

@copilot my bad, remove node26 from CI

Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot my bad, remove node26 from CI

Removed Node.js 26.x from the CI test matrix. Now testing only 20.x and latest.

Commit: 023a084

Copilot finished work on behalf of albertorestifo November 5, 2025 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants