fix(types): add typed responses for postOrder and market data#325
fix(types): add typed responses for postOrder and market data#325Aboudjem wants to merge 3 commits into
Conversation
…id breaking changes Keep success, errorMsg, transactionsHashes, takingAmount, and makingAmount as required fields (matching upstream) and add transactTime/owner as optional. This resolves the Bugbot finding about divergent type definitions without breaking existing consumers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| readonly next_cursor: string; | ||
| readonly data: any[]; | ||
| readonly data: T[]; | ||
| } |
There was a problem hiding this comment.
PaginationPayload default breaks consumers using bare type
Medium Severity
The default type parameter for PaginationPayload changed from an effective any (via data: any[]) to T = unknown, making bare PaginationPayload resolve data to unknown[] instead of any[]. Since this is a publicly exported type from an npm package, any downstream consumer referencing PaginationPayload without a type argument will now get compilation errors when accessing properties on data items. Using T = any as the default would preserve backward compatibility while still enabling generic usage.


Summary
PostOrderResponseinterface forpostOrder/createAndPostOrder/createAndPostMarketOrderPaginationPayload<T>generic sodataisT[]instead ofany[]MarketandSimplifiedMarkettype definitions based on API response shapesPromise<any>to properly typed promisesChanges
src/types.tsPostOrderResponse,Market,SimplifiedMarketinterfaces; madePaginationPayloadgenericsrc/client.tstests/client/types.test.tsTest plan
pnpm build— cleanpnpm typecheck— cleanpnpm lint— cleanvitest run— 169 tests pass (156 existing + 13 new)Fixes #307
Fixes #309
Note
Medium Risk
Runtime behavior is unchanged, but the new/stricter TypeScript return types (including generic pagination) may be a breaking change for downstream consumers relying on
anyor different response shapes.Overview
Improves the public client API typing by replacing
anyreturn types with explicit models for market endpoints and order submission.Adds
Market/SimplifiedMarketinterfaces, makesPaginationPayloadgeneric so paginateddatais strongly typed, and updatespostOrder/createAndPostOrder/createAndPostMarketOrder(plus market fetchers likegetMarket/getMarkets) to returnOrderResponse/typed pagination. Includes new tests to assert the expected type shapes.Written by Cursor Bugbot for commit 633394a. This will update automatically on new commits. Configure here.