-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
rawCheck
accepts a function that returns a Promise
#832
Comments
This is because the return type |
Thanks for the hint! I am not sure what to do. |
I found two ideas that might work:
I don't think the first idea is enough to handle all of the cases. So let's forget it. The second idea might work. I'll talk about it below. function rawCheck(callback: () => (undefined | void)) {
}
rawCheck(() => { }); // () => undefined
rawCheck(() => { return; }); // () => undefined
rawCheck(() => undefined); // () => undefined
const voidFn: () => void = () => 12;
rawCheck(voidFn); // () => void These cases are flagged as errors: rawCheck(() => null); // () => null
rawCheck((() => 12)); // () => 12
rawCheck(async () => { }); // () => Promise<null> I feel this is a reasonably ask as const anotherVoidFn: () => void = async () => 12;
rawCheck(anotherVoidFn); Even though the example is simple, I think large codebases can easily be in a similar situation. I would recommend using
What do you think? |
I think I don't want to make a decision right now, as other things are much more important and |
The code block shown below should generate a type error as
rawCheck
might not be designed to use async functions.The text was updated successfully, but these errors were encountered: