Skip to content
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

Closed
wh1t3cAt1k opened this issue Aug 25, 2020 · 1 comment · Fixed by #1106
Closed

bulkAdd & bulkPut typing: accept a readonly array #1105

wh1t3cAt1k opened this issue Aug 25, 2020 · 1 comment · Fixed by #1106

Comments

@wh1t3cAt1k
Copy link
Contributor

We follow immutability practices in our codebase, but because of the current typings, bulkAdd and bulkPut do not accept a readonly TEntity[], only TEntity[].

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!

@dfahlander
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants