Skip to content
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] Using NotificationRequest throws a TypeError: NotificationRequest is not a constructor #1464

Open
romulovalez opened this issue Feb 12, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@romulovalez
Copy link

romulovalez commented Feb 12, 2025

Describe the bug
Using NotificationRequest throws a TypeError: NotificationRequest is not a constructor

It's a type issue, It seems like NotificationRequest generated type is wrong and don't support its use on ESM modules properly

To Reproduce

import NotificationRequest from '@adyen/api-library/lib/src/notification/notificationRequest';

console.log(new NotificationRequest({ live: 'false', notificationItems: [] }));

Execute it with npx tsx script.ts

Expected behavior

It should work and show { notificationItemContainers: [], live: 'false' } but it's throwing this error:

console.log(new NotificationRequest({ live: 'false', notificationItems: [] }));
            ^


TypeError: NotificationRequest is not a constructor
    at <anonymous> (/script.ts:4:13)
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:122:5)

Node.js v20.18.1

I workaround with this:

import NotificationRequestWronglyTyped from '@adyen/api-library/lib/src/notification/notificationRequest';

// @ts-expect-error this NotificationRequest type is wrong
const NotificationRequest = NotificationRequestWronglyTyped.default as unknown as typeof NotificationRequestWronglyTyped;

console.log(new NotificationRequest({ live: 'false', notificationItems: [] }));

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS Sequoia 15.3 (24D60)
  • Node Version: 20.18.1
  • NPM Version: pnpm@10.0.0

Additional context
Add any other context about the problem here.

@romulovalez romulovalez added the bug Something isn't working label Feb 12, 2025
@ayodejidev
Copy link
Contributor

Hi @romulovalez,

Thanks for reporting this issue. I followed the steps you provided but was unable to reproduce the error. I'm getting the expected output:
{ notificationItemContainers: [], live: 'false' }.

Could you share the version of the Node API library you're currently using?

Also, you can try cloning the repository and running this test locally to see if the issue persists on your end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants