Skip to content

Use ReadonlyArray instead of Array for read-only parameters in callback APIs #2321

Open
@haijian-vaadin

Description

@haijian-vaadin

In some callback APIs, for example, the

GridDataProviderCallback<TItem> = (items: Array<TItem>, size?: number) => void;

The items param is supposed to be read-only, but the type is writeable Array. Would be better to change it from Array to ReadonlyArray.

Also, the readonly property change in Fusion would make the starter project fail on TS errors (e.g. in the master-details view) in Vaadin 22.

There is a discussion going on for updating the statement management in the starter project. This ticket is only about the imminent need to get the starter project work.
It could be either fixed by updating the callback API to use ReadonlyArray or having a workaround in the starter, e.g.

const data = (await SamplePersonEndpoint.list(index, params.pageSize, params.sortOrders as any)) as SamplePerson[];
callback(data ?? []);

updating the API looks better.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions