-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Exporter enum types incorrect #494
Comments
At the moment I am using those typings in my project to handle webhook notifications. To be able to use them, I have to import/require them from the dist folder, because the typings are not exported from the index file. Is there a reason why they are not exported? Current import:
Expected import would be inside these imports:
|
Hi @tomdebuyser We have plans to move our types definitions to @types so they can be used on other typescript projects. Currently, the types are inherited when you use any of the public API's methods and not meant to be used alone. But I think it makes sense to expose the NotificationRequest. Can you check if passing |
Thanks for your answer @KadoBOT I don't really see how this will solve the issue, the enum values will still be invalid? Also types like Creating an @types library with correct typings would definitely help. I know importing from the dist folder is not a good practice, but I explicitly have to type things |
@tomdebuyser yes, it is expected that Here is an example constructing the NotificationRequest using a json with capital N |
@KadoBOT here you see (a part of) my function where I try to map a notification to an internal payment state.
As you can see I want to compare eventCode and success, where I have to use the typings to make my code compile. How can I write this differently without casting these things to |
There are two ways. The one I suggest is comparing to the The other way is a bit hackish but you could try using the function for the eventCode enum which is generated from the compiled Object serializer, here Keep in mind that the last one, is a generated file and we can't provide support for it if you decided to use it. And it might change anytime. That's why I suggest using the |
Ok. Looking forward to the types lib! |
I'll keep this issue open until we release the types. Thanks @tomdebuyser ! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@KadoBOT - any update on this? We also have some other types that it would be nice to be exported so we can import them directly from
It would be ideal to have a type for the entire web hook body |
Hi @hobadams, Thanks for bumping this thread with your suggestion. Kind regards, |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The issue should be opened again or was the enum type problem fixed? It's actually quite problematic as for each and every enum value we have to cast the type to any and then to a string to make our programs works :-/ |
Hi @mjeri, Unfortunately we do not have a fix for your issue at this time. Kind regards, |
Describe the bug
The enum types that are exported in
notificationRequestItem.d.ts
(and probably other files that I do not use yet) are not correct. They only provide a enum name without value. As you can see in the TypeScript enum docs (https://www.typescriptlang.org/docs/handbook/enums.html#numeric-enums), when declaring an enum without values, it will result in a number, while the Adyen API is returning strings.To Reproduce
Install @adyen/api-library and open
notificationRequestItem.d.ts.
Expected behavior
Those enums have a string value, representing the value that is sent from the Adyen API. I created some typings in my own project to get around this bug:
Screenshots
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: