Skip to content

[BUG] Using NotificationRequest throws a TypeError: NotificationRequest is not a constructor #1464

@romulovalez

Description

@romulovalez

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions