You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When possible, it's preferable to accept read-only arrays as arguments. That allows upstream callers to pass read-only arrays or regular arrays in. But passing a read-only array in place of a regular array is disallowed. (Because the function is effectively saying "I might mutate that array", which would break the "read-only-ness" of the ReadonlyArray<T>.)
My problem:
We have some JSON columns.
Some of the app's functions want to write values into those columns, and the values contain some read-only arrays.
It's not possible to write these values (or any value containing a ReadonlyArray) into a postgres-schema-ts JSONValue column. The JSONValue type only allows Array<T>.
My proposed solution:
Change JSONArray to:
export type JSONArray = ReadonlyArray<JSONValue>
I tried to do this myself, but failed to run the tests, and this is definitely a change where I want to see the tests run. I installed docker-compose (v2.3.3, which is current according to homebrew). Still, the tests fail like this:
$ npm run test
> [email protected] test /Users/grb/Downloads/src/postgres-schema-ts
> docker-compose up -d && jest --runInBand --forceExit
(root) Additional property musicbrainz is not allowed
So no PR from me. But looking at the code, this feels like a very quick change.
The text was updated successfully, but these errors were encountered:
Background:
When possible, it's preferable to accept read-only arrays as arguments. That allows upstream callers to pass read-only arrays or regular arrays in. But passing a read-only array in place of a regular array is disallowed. (Because the function is effectively saying "I might mutate that array", which would break the "read-only-ness" of the
ReadonlyArray<T>
.)My problem:
ReadonlyArray
) into a postgres-schema-tsJSONValue
column. TheJSONValue
type only allowsArray<T>
.My proposed solution:
Change
JSONArray
to:I tried to do this myself, but failed to run the tests, and this is definitely a change where I want to see the tests run. I installed docker-compose (v2.3.3, which is current according to homebrew). Still, the tests fail like this:
So no PR from me. But looking at the code, this feels like a very quick change.
The text was updated successfully, but these errors were encountered: