-
Notifications
You must be signed in to change notification settings - Fork 85
Description
Describe the bug
Compiled d.ts files for enums do not include assigned values and become numeric enums from the perspective of TS.
To Reproduce
This behavior can be observed in notificationRequestItem.d.ts
export declare namespace NotificationRequestItem {
enum EventCodeEnum {
Authorisation,
AuthorisationAdjustment,
Cancellation,
CancelOrRefund,
Capture,
CaptureFailed,
...other enum values
}
enum OperationsEnum {
Cancel,
Capture,
Refund
}
enum SuccessEnum {
True,
False
}
}The cause behind it is the addition of <any> to each enum value in the original typescript definition
export namespace NotificationRequestItem {
export enum EventCodeEnum {
Authorisation = <any> 'AUTHORISATION',
AuthorisationAdjustment = <any> 'AUTHORISATION_ADJUSTMENT',
Cancellation = <any> 'CANCELLATION',
CancelOrRefund = <any> 'CANCEL_OR_REFUND',
Capture = <any> 'CAPTURE',
CaptureFailed = <any> 'CAPTURE_FAILED',
...other enum values
}
export enum OperationsEnum {
Cancel = <any> 'CANCEL',
Capture = <any> 'CAPTURE',
Refund = <any> 'REFUND'
}
export enum SuccessEnum {
True = <any> 'true',
False = <any> 'false'
}
}Expected behavior
String enums from typescript files are preserved as string enums in the compiled type definitions.
Additional context
This behavior makes the Adyen Node API Library challenging to depend on. Writing code to handle specific events or checking success cases forces the creation of custom-built constructs and manual casts, decreasing code maintainability (keeping a clone string enum) and safety (the clone string enum is prone to uncaught changes to Adyen's underlying enums). I understand that this is due to the code generator being used, but it affects the implementation quality of anyone using the Adyen Node API Library and should be addressed.