Conversation
| // TypeScript Version: 3.7 | ||
| declare module "effection" { | ||
| export type Operation = OperationFn | Sequence | Promise<any> | Controller | undefined; | ||
| export type Operation<T = any> = undefined | OperationFn<T> | Sequence<T> | PromiseLike<T> | Controller<T>; |
There was a problem hiding this comment.
I've defaulted these types to any, to maximize compatibility with existing code.
|
A preview package of this pull request has been released to NPM with the tag $ npm install effection@generic-typesor by updating your package.json to: {
"effection": "generic-types"
}Once the branch associated with this tag is deleted (usually once the PR is merged or closed), it will no longer be available. However, it currently references effection@0.5.1-5f59183 which will be available to install forever. |
This way the result of an operation can be carried forward, which makes typechecking better, since we can infer the type of the variable that invokes the yield.
|
A preview package of this pull request has been released to NPM with the tag $ npm install effection@generic-typesor by updating your package.json to: {
"effection": "generic-types"
}Once the branch associated with this tag is deleted (usually once the PR is merged or closed), it will no longer be available. However, it currently references effection@0.5.1-c4bcde1 which will be available to install forever. |
cowboyd
left a comment
There was a problem hiding this comment.
Looks good, although I do think that we need to change the type of timeout. Also, what is the tradeoff of using unknown instead of any. The reason I say is that it might help us get to noImplicitAnysville sooner
|
A preview package of this pull request has been released to NPM with the tag $ npm install effection@generic-typesor by updating your package.json to: {
"effection": "generic-types"
}Once the branch associated with this tag is deleted (usually once the PR is merged or closed), it will no longer be available. However, it currently references effection@0.5.1-d5d18e3 which will be available to install forever. |
This way the result of an operation can be carried forward, which makes typechecking better. Adding these generic types doesn't make a huge difference, but at least it complains when we get the return value of a generator function wrong, which is nice.