Skip to content

feat: remove readonly constraint from response related types #1064

@nunomaduro

Description

@nunomaduro

TL; DR: Go to every type that ends with ...Response.ts and remove readonly keywords.

A good type-system prevents problems from happening - that's why, by default, the given params to a async function in the client most be readonly. So they can't be modified while the promise is being resolved in background. Here is an example:

client.search('foo', params).then(console.log);
params.foo = 'bar'; // TYPE-ERROR: because those params may still be used inside the `search` function.

In the other hand, having readonly responses prevents the user from doing manipulations to the response object, and that's is annoying:

const response await client.search('foo', params);
delete response.hits; // TYPE-ERROR: grrrrrr
const myCustomObject = response;

Since having readonly responses add no value to the user or to us, to fix this problem, go to every type that ends with ...Response.ts and remove readonly keywords.

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