RJR
Convex Community3y ago
2 replies
RJ

TS readonly Convex values

I've run into the issue a few times of having a readonly value, like
readonly number[]
, which I'd like to pass in as an argument to something like
db.insert
for a table whose schema is
v.array(v.number())
. TypeScript sees
readonly number[]
as unassignable to the type
number[]
, and gives me a type error.

I wonder how the DX might be improved here? Would it be too ungainly to have
v.array<T>
produce the type
readonly T[] | T[]
(same with
v.object
)?

For what it's worth, I just about never use
readonly
in my own code (and am not too familiar even with what it purports to guarantee, or not)—these examples have come from types in third-party libraries.
Was this page helpful?