Skip to content

fix(typescript): make Position fields nullable to match core#1418

Open
AbhilashG12 wants to merge 2 commits into
pmxt-dev:mainfrom
AbhilashG12:fix/typescript-position-nullable
Open

fix(typescript): make Position fields nullable to match core#1418
AbhilashG12 wants to merge 2 commits into
pmxt-dev:mainfrom
AbhilashG12:fix/typescript-position-nullable

Conversation

@AbhilashG12

Copy link
Copy Markdown
Contributor

What this PR does

Fixes TypeScript Position interface to match core and Python SDK.

The Problem

Four Position fields are typed as string / number but the hosted API returns null:

  • outcomeLabel
  • entryPrice
  • currentPrice
  • unrealizedPnL

The Fix

Added | null to all four fields.

Why it matters

TypeScript users will now get proper type warnings when handling nullable fields.

Fixes #1405

- outcomeLabel: string → string | null
- entryPrice: number → number | null
- currentPrice: number → number | null
- unrealizedPnL: number → number | null

These fields can be null in hosted mode when mark-to-market data
or fill history is unavailable.

Fixes pmxt-dev#1405
@realfishsam

Copy link
Copy Markdown
Contributor

PR Review: PASS (NOT VERIFIED)

What This Does

Updates the TypeScript SDK Position interface so hosted-mode nullable enrichment fields are typed as string | null / number | null instead of only non-null primitives. This matters to SDK consumers because hosted responses may include null for mark-to-market/fill-derived fields that are unavailable.

Blast Radius

TypeScript SDK model type surface only: sdks/typescript/pmxt/models.ts Position. No Python SDK, server, OpenAPI, exchange normalizer, or converter logic changed.

Consumer Verification

Before (base branch):
Position.outcomeLabel, entryPrice, currentPrice, and unrealizedPnL were optional but not nullable in the TypeScript SDK model. A consumer assigning a hosted response shape with null for these fields would fail TypeScript type checking even though the runtime converter (convertPosition) simply spreads the raw response.

After (PR branch):
On PR head 0578377, sdks/typescript/pmxt/models.ts:352, :358, :361, and :364 declare those fields as string | null / number | null. A focused TypeScript consumer probe assigning null to all four fields in a Position passed with tsc --noEmit --skipLibCheck ....

Test Results

  • Build: NOT VERIFIED — npm run build --workspace=pmxtjs is blocked in this review checkout by missing generated SDK artifacts: pmxt/client.ts(15,8): error TS2307: Cannot find module '../generated/src/index.js' and pmxt/server-manager.ts(7,43): error TS2307.
  • Unit tests: NOT RUN because the TypeScript SDK build is blocked by missing generated artifacts.
  • Server starts: N/A — SDK model type-only change.
  • E2E smoke: PASS (focused type smoke only): a TypeScript Position object with null values for the changed fields type-checked successfully.

Findings

No blocking findings.

PMXT Pipeline Check

  • Field propagation (3-layer): N/A — this is TypeScript SDK model nullability alignment for an existing response shape, not a new field.
  • OpenAPI sync: N/A — no OpenAPI change in this PR.
  • Financial precision: N/A — no arithmetic changed.
  • Type safety: OK — nullable hosted fields are now represented in the TS surface.
  • Auth safety: N/A

Semver Impact

patch -- widens TypeScript SDK field types to accept runtime-null values without changing behavior.

Risk

Full TypeScript SDK build was not verified because generated artifacts are absent in the checkout. Also, this PR leaves inline // ✅ Added | null comments in the interface; not blocking, but they are a bit noisy for a published SDK surface file.

Clean up noisy comments from published SDK surface.

Fixes pmxt-dev#1405
@AbhilashG12

Copy link
Copy Markdown
Contributor Author

✅ Ready to Merge!

Thanks for the review! I've removed the inline comments from the Position interface.

The build failure is due to missing generated artifacts in the review environment - the changes are correct.

Ready to merge! 🚀

@realfishsam

Copy link
Copy Markdown
Contributor

PR Review: PASS (NOT VERIFIED)

What This Does

This widens the TypeScript SDK Position interface so hosted-mode nullable position enrichment fields (outcomeLabel, entryPrice, currentPrice, unrealizedPnL) can be represented as null as well as omitted. That matters to SDK consumers because the core/OpenAPI/Python surfaces already document these values as nullable when mark-to-market data or fill history is unavailable.

Blast Radius

TypeScript SDK model types only: sdks/typescript/pmxt/models.ts. No exchange implementation, router, server, OpenAPI generator, or generated SDK files changed.

Consumer Verification

Before (base branch):
Type-level consumer probe assigning hosted-null fields to Position fails on current origin/main:

import type { Position } from './sdks/typescript/pmxt/models';
const position: Position = {
  marketId: 'm1', outcomeId: 'o1', size: 1,
  outcomeLabel: null,
  entryPrice: null,
  currentPrice: null,
  unrealizedPnL: null,
};

Command:

./node_modules/.bin/tsc --noEmit --strict --skipLibCheck --moduleResolution node --target ES2022 --module ESNext position-null-probe.ts

Base result:

position-null-probe.ts(7,3): error TS2322: Type 'null' is not assignable to type 'string | undefined'.
position-null-probe.ts(8,3): error TS2322: Type 'null' is not assignable to type 'number | undefined'.
position-null-probe.ts(9,3): error TS2322: Type 'null' is not assignable to type 'number | undefined'.
position-null-probe.ts(10,3): error TS2322: Type 'null' is not assignable to type 'number | undefined'.

After (PR branch):
The same focused type-level consumer probe passes on head d03ac6bc3ed023c1900b9180e79d03d7cf07f3c2 with no compiler output.

Sidecar HTTP verification was not applicable: this PR changes TypeScript type declarations only, not runtime server behavior or SDK mapping logic.

Test Results

  • Build: FAIL (blocked by pre-existing missing generated TypeScript SDK artifact: pmxt/client.ts(15,8): error TS2307: Cannot find module '../generated/src/index.js')
  • Unit tests: FAIL for 3 suites that import pmxt/client.ts with the same missing generated artifact; 4 suites passed, 29 tests passed
  • Server starts: NOT RUN (not relevant to a TypeScript type-only model change)
  • E2E smoke: NOT RUN (no runtime API behavior changed)
  • Focused type probe: PASS (Position accepts null for the four hosted-nullable fields)

Findings

No blocking findings.

PMXT Pipeline Check

  • Field propagation (3-layer): OK — core Position and core/src/server/openapi.yaml already mark these fields nullable; this PR aligns the TypeScript SDK model type.
  • OpenAPI sync: N/A — no core schema or generator change.
  • Financial precision: N/A — type-only change, no arithmetic/runtime values changed.
  • Type safety: OK — focused tsc --strict probe verifies the intended consumer type behavior.
  • Auth safety: N/A

Semver Impact

patch -- TypeScript type correction for already-documented hosted-mode nullable fields.

Risk

Full pmxtjs build and all tests remain not fully verified in this checkout because generated SDK artifacts are missing (../generated/src/index.js). Runtime hosted mapper comments still say missing optional fields surface as undefined; that is not contradicted by this PR, but I did not verify a live hosted response that returns explicit null values.

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.

TypeScript SDK Position fields outcomeLabel/entryPrice/currentPrice/unrealizedPnL typed non-nullable; core and Python SDK use T | null

2 participants