Skip to content

Dont Repeat Yourself/Open Helper #4

@idkjs

Description

@idkjs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions