-
-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bulkAdd & bulkPut typing: accept a readonly
array
#1105
Comments
Yes, it's true we could add the readonly attribute into bulkAdd and bulkPut and I thing we should. PR's would be welcome. First change table.d.ts under src/public/types. Then go ahead and change the implementations as TSC will start complaining. It might require a change all the way into DBCoreAddRequest and DBCorePutRequest interfaces but that is ok. DBCore does not alter given arrays in the mutate method. The request objects itself may be extended with the optional key property but the values array will be readonly in practice. |
We follow immutability practices in our codebase, but because of the current typings,
bulkAdd
andbulkPut
do not accept areadonly TEntity[]
, onlyTEntity[]
.If I understand it correctly, the typing could be safely relaxed to allow both the readonly and non-readonly versions of the array.
This would be a small change and would avoid a type assertion in the consuming code.
Thank you!
The text was updated successfully, but these errors were encountered: