Some things that could be a TypeScript type are enum which is quite developer unfriendly. Code completion and many checks just don't work.
The Problem
For example if you have a Payment and want to check its status, the IDE (VS Code in my case) can't give you anything to autocomplete. The type check works though.
Here you should have the statuses as suggestions:

This is the case for every enum including Locale, PaymentMethod etc.
While the missing suggestions are basically just an inconvenience (and missing out on fully utilizing TypeScript and the IDE) using the embed option of the mollieClient.payments.get method just does not work without using any because of the enum:

In contrast to the include option which uses a type:

Changing the PaymentEmbed from an enum to type fixes this:


Suggested Changes
Looking at the source code it seems like this change could be easy.
Lets use the PaymentStatus as an example.
The PaymentStatus enum from src/data/payments/data.ts:825 is used like an Object in src/data/payments/PaymentHelper.ts to check against the payment status.
I would suggest to change src/data/payments/data.ts from this:
export enum PaymentStatus {
open = 'open',
canceled = 'canceled',
pending = 'pending',
authorized = 'authorized',
expired = 'expired',
failed = 'failed',
paid = 'paid',
}
To this:
export const PAYMENT_STATUS = {
open: 'open',
canceled: 'canceled',
pending: 'pending',
authorized: 'authorized',
expired: 'expired',
failed: 'failed',
paid: 'paid',
};
export type PaymentStatus = keyof typeof PAYMENT_STATUS;
And then use it in src/data/payments/PaymentHelper.ts like this:
public isOpen(this: PaymentData): boolean {
return this.status === PAYMENT_STATUS.open;
}
The PaymentStatus is now a type that can be used without problems.

Conclusion
I don't know why you at Mollie use enums instead of types but looking at the code i don't see a good reason. Maybe i just didn't find it yet or maybe there is none. I just know that using the Mollie Node package would be better if they were types not enums.
If this change is welcome i would create a PR for that. But i would need some guidance regarding the API_KEY in the .env file (Just the regular API key or something special?) and regarding the amount of errors when running tsc --noEmit (Do i have to configure something special?). But I also do not insist on doing it myself. 😅
Some things that could be a TypeScript
typeareenumwhich is quite developer unfriendly. Code completion and many checks just don't work.The Problem
For example if you have a
Paymentand want to check its status, the IDE (VS Code in my case) can't give you anything to autocomplete. The type check works though.Here you should have the statuses as suggestions:

This is the case for every
enumincludingLocale,PaymentMethodetc.While the missing suggestions are basically just an inconvenience (and missing out on fully utilizing TypeScript and the IDE) using the
embedoption of themollieClient.payments.getmethod just does not work without usinganybecause of theenum:In contrast to the
includeoption which uses atype:Changing the
PaymentEmbedfrom anenumtotypefixes this:Suggested Changes
Looking at the source code it seems like this change could be easy.
Lets use the
PaymentStatusas an example.The
PaymentStatusenumfromsrc/data/payments/data.ts:825is used like an Object insrc/data/payments/PaymentHelper.tsto check against the payment status.I would suggest to change
src/data/payments/data.tsfrom this:To this:
And then use it in
src/data/payments/PaymentHelper.tslike this:The
PaymentStatusis now a type that can be used without problems.Conclusion
I don't know why you at Mollie use enums instead of types but looking at the code i don't see a good reason. Maybe i just didn't find it yet or maybe there is none. I just know that using the Mollie Node package would be better if they were types not enums.
If this change is welcome i would create a PR for that. But i would need some guidance regarding the API_KEY in the .env file (Just the regular API key or something special?) and regarding the amount of errors when running
tsc --noEmit(Do i have to configure something special?). But I also do not insist on doing it myself. 😅