Skip to content

[Bug]: Incorrect typing on NotificationRequestItem.additionalData #1539

@IggyMi

Description

@IggyMi

Description

Assigned { [key: string]: string; } | undefined is assumes that for any key there's an existing value

Steps to reproduce

The wrong type can be found in

'additionalData'?: { [key: string]: string; };

Actual behavior

NotificationRequestItem.additionalData field has a type that provides false information to the compiler. Accessing values from this field in TS results in string type instead of a string | undefined, as we have no guarantee that for any given key there will be a value, i.e., notificationItem.additionalData['fieldThatDoesNotExist'] will have type of string.

Expected behavior

To avoid the need to override the type manually or have manual not-nil checks, the assigned type could be

export class NotificationRequestItem {
    'additionalData'?: { [key: string]: string | undefined; };

or

export class NotificationRequestItem {
    'additionalData'?: Record<string, string | undefined>;

Code snippet or screenshots (if applicable)

No response

Adyen Node API Library version

28.1.0

Node.js version

20.19.4

NPM version

No response

Operating System

macOS

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions