Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typings problem with PromiseStateMapping/FunctionMapping #226

Open
axon-q opened this issue Feb 18, 2019 · 1 comment
Open

Typings problem with PromiseStateMapping/FunctionMapping #226

axon-q opened this issue Feb 18, 2019 · 1 comment

Comments

@axon-q
Copy link

axon-q commented Feb 18, 2019

Hello! Thanks to those who contributed the TypeScript definitions, they're very useful. I did run into what looks like a problem with the PromiseStateMapping and FunctionMapping definitions. They look like:

type PromiseStateMapping<
  TProps,
  TProp extends keyof TProps
> = TProps[TProp] extends PromiseState<infer TValue>
  ? string | Mapping<TProps, TValue>
  : never;

// Function
type FunctionMapping<
  TProps,
  TProp extends keyof TProps
> = TProps[TProp] extends ((...args: infer TArgs) => void)
  ? ((...args: TArgs) => PropsMap<TProps>)
: never;

The two types

TProps[TProp] extends PromiseState<infer TValue>

and

TProps[TProp] extends ((...args: infer TArgs) => void)

appear to need an | undefined appended to them. Without this, I get (at least with TypeScript 3.3.3) type errors with connect() whenever the refetch props of the component are declared as optional with ?. But all refetch props need to be declared optional, since otherwise users of the component would have to pass them in. Does this sound right or am I missing something?

@ryanbrainard
Copy link
Contributor

@lmontoute, can you comment on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants