-
-
Notifications
You must be signed in to change notification settings - Fork 247
Typings for attach fails if specify effect argument type #439
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
Comments
Looks like you have type error: mapParams returns However, explicit generics usually reveal actual messages: const original = createEffect((params: string) => {
console.log('Original effect called with', params)
})
const data = createStore(8900)
const created = attach<number, typeof data, typeof original>({
effect: original,
source: data,
mapParams: (params, data) => {
console.log('Created effect called with', params, 'and data', data)
return {wrapped: params, data}
},
}) |
Hm, really it was error in typings. Quite dificult to determine error source until write explicit typings... Strange typescript behaviour... Thanks. |
I found, that problem with typing solves if rename overloads of attach with Ho about to extract such attachToSource function? |
Separate methods overwhelm users, there is a direct correlation between amount of methods in api and „this is a large api“ feeling, so I'd rather try to improve inference for attach itself |
Good news! I found a way to show useful error message in your case Will be released in |
Interesting solution, saved for myself. Thanks! |
What is the current behavior:
There exact sample from https://effector.dev/docs/api/effector/attach, but with one change - when calling createEffect I added type for effect argument:
TypeScript 3.8.0 compailns with error:
Which versions of effector packages, and which browser and OS are affected by this issue? Did this work in previous versions of effector?:
"effector": "^21.7.5",
TypeScript 3.8.0
Maybe the last TypeScript will be ok, can't check right now.
The text was updated successfully, but these errors were encountered: