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
The most recent version of io-ts (2.2.21) strips all key/value pairs when encoding using t.record with the NumberFromString codec from io-ts-types like this: t.record<NumberFromString, xxx>.
The previous version of io-ts that I was using (2.2.20) did not have the same issue
That's because there was a bug that has been resolved. In your example:
constmyRecord: Flags={"1": true,"20": false,};
the keys are not numbers ("1", "20" are strings), so they are stripped.
The issue arises from using NumberFromString as a key. You may consider using a different codec that merely validates whether a string is parseable as a number, without performing an actual transformation.
🐛 Bug report
Current Behavior
The most recent version of
io-ts
(2.2.21
) strips all key/value pairs when encoding usingt.record
with theNumberFromString
codec fromio-ts-types
like this:t.record<NumberFromString, xxx>
.Expected behavior
The previous version of
io-ts
that I was using (2.2.20
) did not have the same issue. The expected and previous behavior was:Reproducible example
https://codesandbox.io/p/sandbox/vibrant-tom-cvxrzp?file=%2Fsrc%2Findex.ts
Suggested solution(s)
I don't have a suggested solution at this time, for now I have just reverted back to
io-ts
version2.2.20
and it is working as expected.Additional context
Your environment
Which versions of io-ts are affected by this issue? Did this work in previous versions of io-ts?
Version
2.2.21
is affected, this is working in2.2.20
.The text was updated successfully, but these errors were encountered: