Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

fix(types): add typed responses for postOrder and market data#325

Open
Aboudjem wants to merge 3 commits into
Polymarket:mainfrom
Aboudjem:fix/type-promise-any-returns
Open

fix(types): add typed responses for postOrder and market data#325
Aboudjem wants to merge 3 commits into
Polymarket:mainfrom
Aboudjem:fix/type-promise-any-returns

Conversation

@Aboudjem
Copy link
Copy Markdown

@Aboudjem Aboudjem commented Mar 11, 2026

Summary

  • Defines PostOrderResponse interface for postOrder/createAndPostOrder/createAndPostMarketOrder
  • Makes PaginationPayload<T> generic so data is T[] instead of any[]
  • Adds Market and SimplifiedMarket type definitions based on API response shapes
  • Updates 8 method return types from Promise<any> to properly typed promises

Changes

File What
src/types.ts Added PostOrderResponse, Market, SimplifiedMarket interfaces; made PaginationPayload generic
src/client.ts Updated return types for 8 methods
tests/client/types.test.ts Added type-level tests verifying the new interfaces

Test plan

  • pnpm build — clean
  • pnpm typecheck — clean
  • pnpm lint — clean
  • vitest 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 any or different response shapes.

Overview
Improves the public client API typing by replacing any return types with explicit models for market endpoints and order submission.

Adds Market/SimplifiedMarket interfaces, makes PaginationPayload generic so paginated data is strongly typed, and updates postOrder/createAndPostOrder/createAndPostMarketOrder (plus market fetchers like getMarket/getMarkets) to return OrderResponse/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.

@Aboudjem Aboudjem requested a review from a team as a code owner March 11, 2026 22:47
Comment thread src/types.ts Outdated
Aboudjem and others added 2 commits March 12, 2026 02:39
…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>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread src/types.ts
readonly next_cursor: string;
readonly data: any[];
readonly data: T[];
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

retrieving market data functions returns the type any postOrder returns the type any

1 participant