plexinc / papr

MongoDB TypeScript-aware Models
https://plexinc.github.io/papr/
MIT License
426 stars 22 forks source link

bug: readonly arrays are rejected by TS type for some signatures #828

Open duncanbeevers opened 1 month ago

duncanbeevers commented 1 month ago

🐞 Permit readonly arrays

It should be possible to assign readonly arrays directly to papr payload-accepting methods. Instead, we get a type error;

const payload: { list: readonly number[] } = { list: [456] };
// The type 'readonly number[]' is 'readonly' and cannot be assigned to the mutable type 'number[]'.
await simpleModel.updateOne({ foo: 'foo' }, { $set: payload });