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
Expecting string at name but instead got: undefined
This is good for usage on an error aggregator (eg. honeybadger.io) where you just want to know what went wrong.
An smarter reporter
But there could be an use case for an smarter reporter that would also give suggestions.
Specially because, although the reporter error on the example is correct by saying name property was not provided. It is also obvious (to a human) that it wasn't provided because there's a typo (ie. the object does have a very similar property that even matches the expected type of the value).
A good inspiration could be Elm's error messages.
For the following code
type alias Model={ name :String, password :String}init:Modelinit ={ nam ="", password =""}
The error message is:
-- TYPE MISMATCH ----------------------------------------------- Jump To Problem
Something is off with the body of the `init` definition:
33| { nam = "", password = "" }
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The body is a record of type:
{ nam : String, password : String }
But the type annotation on `init` says it should be:
Model
Hint: Seems like a record field typo. Maybe nam should be name?
Hint: Can more type annotations be added? Type annotations always help me give
more specific messages, and I think they could help a lot in this case!
About use cases
Since io-ts is meant for runtime validation I am not sure if this is something that would be used as much as the "regular" reporter.
The text was updated successfully, but these errors were encountered:
Type '{ nam: string; }' is not assignable to type 'User'.
Object literal may only specify known properties, but 'nam' does not exist in type 'User'. Did you mean to write 'name'?
Current reporter
The reported error from that example would be:
This is good for usage on an error aggregator (eg. honeybadger.io) where you just want to know what went wrong.
An smarter reporter
But there could be an use case for an smarter reporter that would also give suggestions.
Specially because, although the reporter error on the example is correct by saying
name
property was not provided. It is also obvious (to a human) that it wasn't provided because there's a typo (ie. the object does have a very similar property that even matches the expected type of the value).A good inspiration could be Elm's error messages.
For the following code
The error message is:
About use cases
Since io-ts is meant for runtime validation I am not sure if this is something that would be used as much as the "regular" reporter.
The text was updated successfully, but these errors were encountered: