Uncaught Error: Trying to send an unexpected type of value through port `items`:
I ran into the following problems at _[0].geolocation:
Expecting null but instead got: {"coords":{"accuracy":24,"latitude":47.5324616,"longitude":12.2500232},"timestamp":1503248041607}
Expecting an object with a field named `altitude` at _.coords but instead got: {"accuracy":24,"latitude":47.5324616,"longitude":12.2500232}
(stacktrace from obfuscated code. I use the firebase SDK)
at send (main.js:13268)
at main.js:32923
at main.js:26332
at fc (main.js:26196)
at bf (main.js:26261)
at cf (main.js:26260)
at Qg.g.Gb (main.js:26351)
at Ag.g.wd (main.js:26315)
at og.wd (main.js:26305)
at Yf.Xf (main.js:26303)
The Type signatures:
type alias JsonItem = {
description : String,
image : String,
price : Int,
title : String,
id: String,
geolocation: Maybe Position
}
-- JS-API morphic
type alias Position = {
coords: Coordinates
, timestamp: Int
}
type alias Coordinates =
{
accuracy : Float
, altitude : Maybe Float
, altitudeAccuracy : Maybe Float
, heading : Maybe Float
, latitude : Float
, longitude : Float
, speed : Maybe Float
}
The ports:
port submit : JsonItem -> Cmd msg
port items : (List JsonItem -> msg) -> Sub msg
Summary I have two ports: One outbound and one inbound. They accept the same type essentially. The inbound port takes an array of that type.
Then inbound port was choking on the incoming data.
The fix was to provide null for any undefined field in geolocation or set geolocation to null if itself was undefined.
The error message:
The Type signatures:
The ports:
Outbound data:
Inbound data