Enforce exact optional properties across the SDK#422
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (16)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
CI is green on the latest head, including the full OCP QuickStart integration suite. @copilot review |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Pull request overview
This PR enables TypeScript’s exactOptionalPropertyTypes across the SDK build/test toolchain and updates SDK code + tests to avoid materializing absent optional fields as undefined (favoring omission), including a small but intentional behavior adjustment in the PPS-based warrant discount mapping.
Changes:
- Enable
exactOptionalPropertyTypesin the primarytsconfig.jsonand remove the now-redundant source-only exactness config + npm script. - Update integration/unit tests and helpers to omit optional fields (via conditional spreads /
withCapTableContractDetails) rather than assigningundefined. - Adjust
warrantMechanismToDamlPPS discount emission to key off!== undefinedfor optional discount fields.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Enables exactOptionalPropertyTypes for the primary compile. |
| tsconfig.exact-source.json | Removes the redundant source-only exactness config. |
| package.json | Drops the test:exact-source script and simplifies typecheck. |
| src/functions/OpenCapTable/shared/conversionMechanisms.ts | Updates PPS-based warrant discount mapping to rely on !== undefined checks. |
| test/validation/boundaries.test.ts | Updates boundary test to omit optional OCF fields rather than setting undefined. |
| test/mocks/fairmint-canton-node-sdk.ts | Adjusts mock fields to be T | undefined (instead of ?:) to comply with exact optional semantics. |
| test/integration/utils/setupTestData.ts | Adds withCapTableContractDetails helper and replaces undefined assignments with conditional spreads. |
| test/integration/production/productionDataRoundtrip.integration.test.ts | Uses withCapTableContractDetails and requireCreatedEventBlob for stricter optional handling. |
| test/integration/entities/valuationVesting.integration.test.ts | Uses withCapTableContractDetails to omit absent contract details. |
| test/integration/entities/transferTypes.integration.test.ts | Uses withCapTableContractDetails to omit absent contract details. |
| test/integration/entities/stockClassAdjustments.integration.test.ts | Uses withCapTableContractDetails to omit absent contract details. |
| test/integration/entities/acceptanceTypes.integration.test.ts | Uses withCapTableContractDetails to omit absent contract details. |
| test/client/OcpContextManager.test.ts | Updates test to pass omitted fields ({}) instead of explicit undefined. |
| test/client/OcpClient.test.ts | Updates test to omit per-call observability overrides instead of setting them to undefined. |
| test/capTable/getCapTableState.test.ts | Aligns getActiveContracts mock param typing using Parameters<...>[0]. |
| test/capTable/archiveFullCapTable.test.ts | Aligns getActiveContracts mock param typing using Parameters<...>[0]. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bbce567
into
codex/exact-conversion-triggers
Summary
exactOptionalPropertyTypesin the main TypeScript configuration for production and testsundefinedValidation
npm run typecheck— zero exact-optional diagnosticsnpm run buildnpm run test:declarationsnpm run lintnpm run formatnpm run test:ci— 65 suites / 2,560 tests; 76.82% statements, 69.56% branches, 77.81% functions, 76.96% linesStack
Note
Medium Risk
Broad TypeScript strictness affects optional-property shapes across the public SDK and many call sites; the warrant PPS discount DAML mapping behavior changes slightly for edge cases around zero/empty discount amounts.
Overview
Turns on
exactOptionalPropertyTypesin the maintsconfigso production and test code share one stricter compile, and drops the separatetest:exact-source/tsconfig.exact-source.jsonpath now thattypecheckno longer needs a second pass.Call sites stop materializing
undefinedon optional fields: integration/setup helpers addwithCapTableContractDetails(and similar conditional spreads) so absent disclosed-contract details and OCF fields are omitted rather than set toundefined.warrantMechanismToDamlfor PPS discounts now keys off!== undefinedfordiscount_percentage/discount_amountinstead ofin/ truthiness checks.Tests and mocks are aligned with the new rules—
Parameters<>for ledger mocks, observability tests that omit per-call overrides, andrequireCreatedEventBlobwhere blobs must be present.Reviewed by Cursor Bugbot for commit 2cbb203. Bugbot is set up for automated code reviews on this repo. Configure here.