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

"clock should extend target type" error while logically correct forwarding #890

Open
yumauri opened this issue Apr 21, 2023 · 0 comments
Open
Labels
typings Typescript public type definitions issues

Comments

@yumauri
Copy link
Contributor

yumauri commented Apr 21, 2023

This code

const a = createEvent<{ a: any }>()
const b = createEvent<{ b?: any }>()

sample({
  clock: a,
  target: b
})

complains

Argument of type '{ clock: Event<{ a: any; }>; target: Event<{ b?: any; }>; }' is not assignable to parameter of type '{ error: "clock should extend target type"; targets: { clockType: { a: any; }; targetType: { b?: any; }; }; }'.
  Object literal may only specify known properties, and 'clock' does not exist in type '{ error: "clock should extend target type"; targets: { clockType: { a: any; }; targetType: { b?: any; }; }; }'.(2345)

I think it is incorrect, because logically it should be absolutely fine to forward { a: any } to { b?: any }. Correct me if I am wrong.
Same issue happens with sample, split, forward and maybe other methods too.

@yumauri yumauri added the typings Typescript public type definitions issues label Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typings Typescript public type definitions issues
Projects
None yet
Development

No branches or pull requests

1 participant