github-reason-react-tutorial icon indicating copy to clipboard operation
github-reason-react-tutorial copied to clipboard

Dont Repeat Yourself/Open Helper

Open idkjs opened this issue 8 years ago • 0 comments

At the Don't Repeat Yourself/ open helper section of your demo. The following proposed code throws an error:

let parseRepoJson = (json: repo) =>
  Json.Decode.{
    full_name: field("full_name", string, json),
    stargazers_count: field("stargazers_count", int, json),
    html_url: field("html_url", string, json)
  };

-error:

./src/index.re
Module build failed: Error: We've found a bug for you!
  /Users/shingdev/code/REASON/reason-repo-list/src/RepoData.re 29:41-44

  27 │ let parseRepoJson = (json: repo) =>
  28 │ Json.Decode.{
  29 │   full_name: field("full_name", string, json),
  30 │   stargazers_count: field("stargazers_count", int, json),
  31 │   html_url: field("html_url", string, json)

  This is:
    repo
  But somewhere wanted:
    at <anonymous>ined as Js.Json.t)

Adding back the Js.Json.t from the original verbose example makes the error go away.

let parseRepoJson = (json: Js.Json.t): repo =>
 Json.Decode.{
  full_name: field("full_name", string, json),
  stargazers_count: field("stargazers_count", int, json),
  html_url: field("html_url", string, json)
};

Not sure if this is what you intended.

idkjs avatar Nov 16 '17 15:11 idkjs