Open dearlordylord opened 8 months ago
When you parse the result of navigator.geolocation.getCurrentPosition, despite coords object having field values, a codec parsing these values returns them successfully unassigned, e.g. an empty object, even when the values are required
coords
for codec
const geoCoordinatesCodec = t.type({ latitude: t.number, longitude: t.number, });
and
navigator.geolocation.getCurrentPosition((position) => { const result = geoCoordinatesCodec.decode(position.coords); });
result has to be {right: {latitude: ..., longitude: ...}}
{right: {latitude: ..., longitude: ...}}
instead, the result is {right: {}}
{right: {}}
https://github.com/Firfi/io-ts-geo-repro
I expect io-ts either return parse errors or correct value
It seems to be some special object proxying / getters involved in location.coords object
if I do
const result = geoCoordinatesCodec.decode({ latitude: position.coords.latitude, longitude: position.coords.longitude });
it works as expected
macos + chrome,
osx + safari
https://github.com/Firfi/io-ts-geo-repro - latest
🐛 Bug report
Current Behavior
When you parse the result of navigator.geolocation.getCurrentPosition, despite
coords
object having field values, a codec parsing these values returns them successfully unassigned, e.g. an empty object, even when the values are requiredExpected behavior
for codec
and
result has to be
{right: {latitude: ..., longitude: ...}}
instead, the result is
{right: {}}
Reproducible example
https://github.com/Firfi/io-ts-geo-repro
Suggested solution(s)
I expect io-ts either return parse errors or correct value
Additional context
It seems to be some special object proxying / getters involved in location.coords object
if I do
it works as expected
Your environment
macos + chrome,
osx + safari
https://github.com/Firfi/io-ts-geo-repro - latest