Skip to content

fix(types): correct invoice log param and utilityPayment id type - #171

Open
mateussiqueira wants to merge 1 commit into
starkbank:masterfrom
mateussiqueira:fix/typescript-type-bugs
Open

fix(types): correct invoice log param and utilityPayment id type#171
mateussiqueira wants to merge 1 commit into
starkbank:masterfrom
mateussiqueira:fix/typescript-type-bugs

Conversation

@mateussiqueira

Copy link
Copy Markdown

Description

Two TypeScript type definition fixes found while reviewing the SDK.

1. invoice.log.query() and invoice.log.page() use wrong param name (#114)

The type definitions use paymentIds in the function signature, but the JS runtime destructures invoiceIds. TypeScript users passing paymentIds would have their filter silently ignored — the value goes nowhere.

The JSDoc @param already correctly says invoiceIds, so this was a copy-paste mistake from other payment-type log modules (which correctly use paymentIds for their domain).

2. UtilityPayment.id should not be optional (#113)

// Before:
readonly id?: string | null

// After:
readonly id: string

The id is always returned by the API for existing payments. Having it as string | null | undefined forces unnecessary null checks on users who retrieve payments. The constructor still accepts id?: string | null for creation scenarios.

Testing

  • No runtime changes — only TypeScript type definitions were updated
  • npm test (mocha) passes
  • npm run test:typescript (jest) passes

Closes #113
Closes #114

Two TypeScript type definition fixes:

1. Invoice log query/page params used 'paymentIds' instead of 'invoiceIds',
   which silently ignores the filter because the JS runtime destructures
   'invoiceIds'. The JSDoc @param was already correct.

2. UtilityPayment readonly id was typed as optional (?string | null),
   but the API always returns an id for existing payments. Changed to
   required 'string' for the class property (constructor keeps it optional
   since ids don't exist at creation time).

Closes starkbank#113
Closes starkbank#114
@mateussiqueira

Copy link
Copy Markdown
Author

Follow-up: algum feedback sobre este PR? Corrige os tipos de invoice log (paymentIds → invoiceIds) e torna UtilityPayment.id obrigatório.

Esses bugs de tipo afetam usuários TypeScript que usam strict mode.

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.

utilityPayment id is possible null/undefined in type invoice.log.query expects paymentIds but only works with invoiceIds

1 participant