Skip to content

fix(ts-sdk): align router match nullability types - #1903

Open
11suixing11 wants to merge 1 commit into
pmxt-dev:mainfrom
11suixing11:fix/ts-router-nullable-types
Open

fix(ts-sdk): align router match nullability types#1903
11suixing11 wants to merge 1 commit into
pmxt-dev:mainfrom
11suixing11:fix/ts-router-nullable-types

Conversation

@11suixing11

@11suixing11 11suixing11 commented Jul 28, 2026

Copy link
Copy Markdown

Summary

  • Make MatchResult and PriceComparison expose reasoning, bestBid, and bestAsk as required nullable TypeScript SDK fields.
  • Normalize the TypeScript router mappers so missing match and price values become null instead of undefined.
  • Add exact compile-time contract assertions plus runtime tests through fetchMarketMatches, compareMarketPrices, and fetchHedges.
  • Verify that valid zero-valued prices remain 0 during null normalization.

Why

Fixes #1401.
Fixes #1402.

main already includes | null for these fields, so this PR finishes the remaining contract mismatch: core returns the fields as present-but-nullable, while the TypeScript SDK still allowed them to be omitted via ?:.

Verification

  • npm ci
  • OpenAPI Generator 7.18.0 via Docker, followed by scripts/fix-generated.js and scripts/generate-client-methods.js
  • npm test --workspace=pmxtjs -- --runTestsByPath tests/router-nullability.test.ts --runInBand (3 tests)
  • npx tsc --noEmit --strict --module CommonJS --target ES2022 --moduleResolution Node --types jest,node tests/router-nullability.test.ts from sdks/typescript/
  • npm test --workspace=pmxtjs -- --runInBand (18 suites, 96 tests)
  • npm run build --workspace=pmxtjs (CommonJS and ESM)
  • npm test --workspace=pmxt-core -- --runInBand (51 suites, 822 tests; 1 suite and 3 tests skipped)
  • npm test (full repository verification; 267 selected Python SDK tests)
  • git diff --check

Notes

  • Generated SDK outputs were created locally for verification but are ignored and not included in this PR.
  • npm ci reports existing audit findings; this PR does not change dependencies.

Copilot AI review requested due to automatic review settings July 28, 2026 05:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns the TypeScript SDK’s router model contract with core by making MatchResult and PriceComparison fields required but nullable, and ensuring router mappers normalize missing values to null (not undefined). This closes the remaining nullability mismatch described in #1401 and #1402.

Changes:

  • Make reasoning, bestBid, and bestAsk required T | null fields in MatchResult and PriceComparison TypeScript SDK models.
  • Update router mapping logic so absent match/price fields are emitted as explicit null.
  • Add a TypeScript-level regression test to prevent reintroducing optional/undefined drift and to assert mapper normalization.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
sdks/typescript/pmxt/models.ts Updates public SDK model types so match/price fields are required-but-nullable, matching core’s contract.
sdks/typescript/pmxt/router.ts Normalizes router mapper outputs so missing reasoning/prices become null instead of undefined.
sdks/typescript/tests/router-nullability.test.ts Adds a regression test covering both the type contract (compile-time) and mapper normalization (source-level assertions).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@11suixing11
11suixing11 marked this pull request as ready for review July 28, 2026 06:08
@11suixing11
11suixing11 force-pushed the fix/ts-router-nullable-types branch from 732df25 to 03544bc Compare July 30, 2026 13:52
Copilot AI review requested due to automatic review settings July 30, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants