Skip to content

fix(types): OrderBookSummary.tick_size should be TickSize, not string - #53

Open
MackDing wants to merge 2 commits into
Polymarket:mainfrom
MackDing:fix/orderbook-tick-size-type
Open

MackDing wants to merge 2 commits into
Polymarket:mainfrom
MackDing:fix/orderbook-tick-size-type

Conversation

@MackDing

@MackDing MackDing commented Apr 30, 2026 •

Copy link
Copy Markdown

Closes #50

Problem

OrderBookSummary.tick_size was typed as string, but the TickSize literal union already exists in the same file:

export type TickSize = "0.1" | "0.01" | "0.001" | "0.0001";

Consumers who want to feed an order book's tick size back into anything that expects TickSize (CreateOrderOptions.tickSize, isTickSizeSmaller, priceValid, the TickSizes map) have to cast or re-validate — which is exactly what #50 reports.

Change

One-line tightening of the type in OrderBookSummary:

- tick_size: string;
+ tick_size: TickSize;

No runtime change, no API contract change. Just restores end-to-end type safety.

Why this is safe

  • The API only ever returns one of those four values. If it ever returns something else, that would already be a backend bug.
  • Every other surface in this package treats tick size as TickSize; this aligns OrderBookSummary with the rest of the codebase.
  • No test changes needed (the value literal still serializes/deserializes as a string at runtime).

Note

Low Risk
Single-field TypeScript narrowing with no runtime or API behavior change; may surface new type errors where consumers assumed arbitrary strings.

Overview
OrderBookSummary.tick_size is now typed as TickSize instead of string, matching how tick sizes are modeled elsewhere (CreateOrderOptions.tickSize, TickSizes, validation helpers).

This is a compile-time-only change: order book responses still carry the same string values at runtime, but callers can pass tick_size into TickSize-expecting APIs without casts or extra validation.

Reviewed by Cursor Bugbot for commit 7628889. Bugbot is set up for automated code reviews on this repo. Configure here.

Closes Polymarket#50

The OrderBookSummary interface declared tick_size as string, but the
TickSize literal union ('0.1' | '0.01' | '0.001' | '0.0001') already
exists and is used consistently elsewhere (CreateOrderOptions.tickSize,
TickSizes map, isTickSizeSmaller/priceValid helpers).

Returning string forces consumers to cast or re-validate before feeding
the value back into any API that expects TickSize. Tightening the type
restores type-safety end-to-end; the API contract itself is unchanged.
@MackDing

Copy link
Copy Markdown
Author

Quick follow-up: this PR appears mergeable from my side; the remaining blocker looks like required maintainer review. Happy to adjust if you prefer a different approach.

@MackDing

Copy link
Copy Markdown
Author

Checking in on this PR. It is still open and appears to be waiting on maintainer review.

I am happy to adjust the scope or add verification details if that would make review easier.

@MackDing

MackDing commented Aug 6, 2026

Copy link
Copy Markdown
Author

Merged the current upstream main into this branch without rewriting history. The final PR diff remains a single type-only change: OrderBookSummary.tick_size is now TickSize, which includes the upstream-added 0.0001 value. No runtime behavior was added.

Validation on the updated head:

  • Biome: 71 files checked, no issues.
  • Vitest: 20 files / 299 tests passed.
  • Build completed successfully for CJS, ESM, and declarations.

This branch has not been deployed

No deployments
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.

Isn't getOrderBook's return type supposed to have tick_size: TickSize?

1 participant