Skip to content

Ship TypeScript type declarations (.d.ts) for the public surface #218

Description

@Sirivasv

Context

bmssp is ESM JavaScript with rich JSDoc but no shipped type declarations. TypeScript consumers currently get any. Types are the single biggest DX ask for an npm library.

Scope

  • Provide .d.ts for the four public exports (BMSSP, Graph, dijkstra, constantDegreeTransform) and the supported BMSSP members (calculateShortestPaths, calculateShortestPathsFrom, bmssp, reconstructPath, getEdges, and the public fields shortestPaths/nodeIDs/hops/preds).
  • Options: hand-write index.d.ts, or generate from the existing JSDoc via tsc --declaration --allowJs --emitDeclarationOnly. Prefer generation if the JSDoc is complete enough, to keep types in lockstep.
  • Add the types (and exports.types) field to package.json; include the .d.ts in the published files.
  • Add a type-level test (e.g. tsd or a // @ts-check sample) so the types are covered in CI.

Constraints

  • Types must match the locked public surface (the test/publicApi.test.mjs contract) — internal members stay untyped/@internal.
  • Non-breaking (additive).

Acceptance

  • A TypeScript sample importing bmssp type-checks with no any on the public surface; CI verifies it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions