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

[TS] `sample` with `target`: "best common type" problem #247

Closed
bloadvenro opened this issue Nov 15, 2019 · 0 comments · Fixed by #248
Closed

[TS] `sample` with `target`: "best common type" problem #247

bloadvenro opened this issue Nov 15, 2019 · 0 comments · Fixed by #248
Labels

Comments

@bloadvenro
Copy link
Contributor

@bloadvenro bloadvenro commented Nov 15, 2019

sample({
  target: {} as Unit<{ a: string; b: string }>,
  source: {} as Unit<{ a: string }>, // should not let such assignment
  //////////////////////////////////////////////////////////////////////////////
  ///////////////// types of props below do not affect anything ////////////////     
  //////////////////////////////////////////////////////////////////////////////
  clock: {} as Unit<any>,
});

sample({
  target: {} as Unit<{ a: string; b: string }>,
  fn: () => ({ a: '' }), // should not let such assignment
  //////////////////////////////////////////////////////////////////////////////
  ///////////////// types of props below do not affect anything ////////////////     
  //////////////////////////////////////////////////////////////////////////////
  source: {} as Unit<any>,
  clock: {} as Unit<any>,
});

Last time we faced with the same problem in forward typings.

I'll add NoInfer<T> type suggested by Typescript comminuty and modify inference for each sample overload which includes target.

@bloadvenro bloadvenro added the typings label Nov 15, 2019
zerobias added a commit that referenced this issue Nov 15, 2019
Sample target forwarding typings
(fix #247)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.