Skip to content

Commit

Permalink
fix(backend): exactOptionalPropertyTypes errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BlairCurrey committed Jan 18, 2024
1 parent 17cc0f6 commit b69e664
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
18 changes: 13 additions & 5 deletions packages/backend/src/open_payments/payment/incoming/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,27 @@ export class IncomingPayment
public toOpenPaymentsType(
walletAddress: WalletAddress
): OpenPaymentsIncomingPayment {
return {
let openPaymentsIncomingPayment: OpenPaymentsIncomingPayment = {

Check failure on line 214 in packages/backend/src/open_payments/payment/incoming/model.ts

View workflow job for this annotation

GitHub Actions / checkout

'openPaymentsIncomingPayment' is never reassigned. Use 'const' instead
id: this.getUrl(walletAddress),
walletAddress: walletAddress.url,
incomingAmount: this.incomingAmount
? serializeAmount(this.incomingAmount)
: undefined,
receivedAmount: serializeAmount(this.receivedAmount),
completed: this.completed,
metadata: this.metadata ?? undefined,
createdAt: this.createdAt.toISOString(),
updatedAt: this.updatedAt.toISOString(),
expiresAt: this.expiresAt.toISOString()
}

if (this.incomingAmount) {
openPaymentsIncomingPayment.incomingAmount = serializeAmount(
this.incomingAmount
)
}

if (this.metadata) {
openPaymentsIncomingPayment.metadata = this.metadata
}

return openPaymentsIncomingPayment
}

public toOpenPaymentsTypeWithMethods(
Expand Down
20 changes: 15 additions & 5 deletions packages/backend/src/payment-method/ilp/peer/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,23 @@ describe('Peer Service', (): void => {
async ({ liquidityThreshold }): Promise<void> => {
const peer = await createPeer(deps)
const { http, maxPacketAmount, staticIlpAddress, name } = randomPeer()
const updateOptions: UpdateOptions = {

let updateOptions: UpdateOptions = {

Check failure on line 235 in packages/backend/src/payment-method/ilp/peer/service.test.ts

View workflow job for this annotation

GitHub Actions / checkout

'updateOptions' is never reassigned. Use 'const' instead
id: peer.id,
http,
maxPacketAmount,
staticIlpAddress,
name,
liquidityThreshold
staticIlpAddress
}

if (maxPacketAmount !== undefined) {
updateOptions.maxPacketAmount = maxPacketAmount
}

if (name !== undefined) {
updateOptions.name = name
}

if (liquidityThreshold !== undefined) {
updateOptions.liquidityThreshold = liquidityThreshold
}

const peerOrError = await peerService.update(updateOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createWalletAddress } from '../../../tests/walletAddress'
import { truncateTables } from '../../../tests/tableManager'
import assert from 'assert'
import { IncomingPaymentState } from '../../../graphql/generated/graphql'
import Objection from 'objection'

Check warning on line 14 in packages/backend/src/payment-method/ilp/stream-credentials/service.test.ts

View workflow job for this annotation

GitHub Actions / checkout

'Objection' is defined but never used

describe('Stream Credentials Service', (): void => {
let deps: IocContract<AppServices>
Expand Down Expand Up @@ -57,12 +58,16 @@ describe('Stream Credentials Service', (): void => {
${IncomingPaymentState.Expired}
`(
`returns undefined for $state incoming payment`,
async ({ state }): Promise<void> => {
await incomingPayment.$query(knex).patch({
state,
expiresAt:
state === IncomingPaymentState.Expired ? new Date() : undefined
})
async ({ state }: { state: IncomingPaymentState }): Promise<void> => {
let paymentPatch: Partial<IncomingPayment> = {

Check failure on line 62 in packages/backend/src/payment-method/ilp/stream-credentials/service.test.ts

View workflow job for this annotation

GitHub Actions / checkout

'paymentPatch' is never reassigned. Use 'const' instead
state
}

if (state === IncomingPaymentState.Expired) {
paymentPatch.expiresAt = new Date()
}

await incomingPayment.$query(knex).patch(paymentPatch)
expect(streamCredentialsService.get(incomingPayment)).toBeUndefined()
}
)
Expand Down

0 comments on commit b69e664

Please sign in to comment.