readonly TransporterOptions
hello team,
I played with the client today and while doing so ended up blocked by (another) readonly issue.
I can not conditionnally construct the options because the requester and all of them are readonly
// Pseudo code
const params = {}
if (!params.requester) {
params.requester = requester; // => Cannot assign to 'requester' because it is a read-only property.
}
const client = algoliasearch('', '', params);
I am not sure what does the readonly solve in function params, did @nunomaduro documented that decision?
Related #1158
it's to make sure that the params don't get modified after the client gets created. You can wrap the params in an as const, which should normally solve the issue
putting as const is as good as having not type at all.
I would be okay to have the interface of SearchClient readonly but the params themselves it's a bit constraining.
@bodinsamuel @Haroenv Just stumbled on this issue while integrating search-insights. The README in the search-insights actually encourages us to modify the transporter options: https://github.com/algolia/search-insights.js#access-usertoken.