Skip to content

Example in README cannot be compiled in TypeScript #243

Description

@kenkoooo

Hi, I tried to compile the following example in 4.0.0-0 in TypeScript, which is in README, but I couldn't compile it.

import { connect, PromiseState } from "react-refetch";

interface Props {
  fooFetch: PromiseState<{}>;
  barFetch: PromiseState<{}>;
}

export default connect<{}, Props>(() => ({
  fooFetch: {
    url: `/foos/1`,
    andThen: foo => ({
      barFetch: `/bar-for-foos-by-id/1`
    })
  }
}))(() => {
  return <a>a</a>;
});

I fixed it like the following it can be compiled.

import { connect, PromiseState } from "react-refetch";

interface Props {
  fooFetch: PromiseState<{}>;
  barFetch: PromiseState<{}>;
}

export default connect<{}, Props>(() => ({
  fooFetch: {
    url: `/foos/1`,
    andThen: foo => ({
      fooFetch: { value: foo },
      barFetch: `/bar-for-foos-by-id/1`
    })
  },
  barFetch: { value: null }
}))(() => {
  return <a>a</a>;
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions