We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Quick fix
Not all constituents of type are callable.
const getValue = <V>(value: V | (() => V)) => typeof value === "function" ? value() : value;
Error occurred
Typescript should understand that expression is callable
The text was updated successfully, but these errors were encountered:
It would still not be safe, because V can be a function type.
V
Related / duplicate: #37663
Sorry, something went wrong.
Yes, it can, but when typeof value === "function" returns true we are 100% sure value is callable
typeof value === "function"
true
value
But you are not sure if it's callable without any arguments. V can be of the type (arg: number) => void as well.
(arg: number) => void
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Bug Report
Quick fix
🔎 Search Terms
Not all constituents of type are callable.
💻 Code
🙁 Actual behavior
Error occurred
🙂 Expected behavior
Typescript should understand that expression is callable
The text was updated successfully, but these errors were encountered: