Skip to content

fix: type safety and SDK parity fixes in TypeScript client#596

Merged
realfishsam merged 1 commit into
mainfrom
fix/453-454-462-470-502-503-ts-client
May 24, 2026
Merged

fix: type safety and SDK parity fixes in TypeScript client#596
realfishsam merged 1 commit into
mainfrom
fix/453-454-462-470-502-503-ts-client

Conversation

@realfishsam
Copy link
Copy Markdown
Contributor

Fixes #453
Fixes #454
Fixes #462
Fixes #470
Fixes #502
Fixes #503

@realfishsam
Copy link
Copy Markdown
Contributor Author

PR Review: PASS (NOT VERIFIED)

What This Does

Multiple type safety and SDK parity fixes in the TypeScript client: (1) adds a question getter as an alias for title on UnifiedMarket for Python SDK parity, (2) types fetchMarketsPaginated parameter as MarketFetchParams instead of any, (3) makes getExecutionPrice synchronous (client-side VWAP calculation instead of server round-trip), (4) adds bestBid/bestAsk fields to MarketOutcome, (5) adds apiKey and pmxtApiKey to PolymarketOptions.

Blast Radius

  • sdks/typescript/pmxt/client.ts -- convertMarket, fetchMarketsPaginated, getExecutionPrice, PolymarketOptions
  • sdks/typescript/pmxt/models.ts -- MarketOutcome, UnifiedMarket

No core or Python changes in this PR (but Python already has question property and bestBid/bestAsk).

Findings

  1. Breaking change: getExecutionPrice changed from async to sync. The return type changes from Promise<number> to number. Any caller doing await exchange.getExecutionPrice(...) will still work (awaiting a non-Promise is valid), but callers using .then() will break. The old implementation delegated to getExecutionPriceDetailed (server call) and returned 0 on partial fills; the new implementation is a local VWAP walk. The behavioral change (always returning VWAP vs. returning 0 for partial fills) is intentional per the fix, but should be noted in release notes.
  2. question getter uses Object.defineProperty with this-based getter. This relies on this being the plain object at runtime. Because convertMarket creates a {...raw, ...} spread, this will correctly refer to the market object. However, the property is non-enumerable, so JSON.stringify(market) will not include question -- this matches the Python @property behavior (not serialized to JSON). This is likely intentional.
  3. PolymarketOptions adds apiKey and pmxtApiKey but these are not wired to anything in this PR. The options interface is extended, but no constructor logic passes these to ExchangeOptions or uses them. This may be forward-looking, but as-is they are dead fields.

PMXT Pipeline Check

  • Field propagation: OK -- bestBid/bestAsk already exist in Python SDK models, now added to TS models. Core already passes these through.
  • OpenAPI sync: N/A -- no core BaseExchange changes
  • Type safety: OK -- removes any on fetchMarketsPaginated

Semver Impact

minor -- new fields on MarketOutcome, new question alias, new interface properties. The getExecutionPrice sync change is technically a breaking signature change (minor or major depending on policy).

Risk

The getExecutionPrice behavior change (sync VWAP walk vs. async server call returning 0 on partial fills) is untested in this PR. The apiKey/pmxtApiKey options are unused. PR 598 and PR 600 both also modify the Python-side create_order/build_order -- ensure merge order doesn't cause conflicts if these are batched.

@realfishsam realfishsam merged commit deb843b into main May 24, 2026
10 of 12 checks passed
@realfishsam realfishsam deleted the fix/453-454-462-470-502-503-ts-client branch May 24, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment