-
Notifications
You must be signed in to change notification settings - Fork 227
feat: remove readonly constraint from response related types #1064
Copy link
Copy link
Closed
Labels
Description
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.
Reactions are currently unavailable