-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Discriminated parameters #24159
Comments
Isn't this already solved with function overloading? |
@MartinJohns Please focus on |
Speaking of function overloading, TypeScript cannot deduce type of one parameter base on another parameter. |
Looks like a duplicate/similar use case of #24085 |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
Search Terms
Suggestion
In Node.js, there's some methods like
fs.readFile
that passes 2 parameters to callback function:(err: Error | null, data: Buffer | null) => void
. Iferr
isnull
thendata
is notnull
and vice versa. It would be extremely useful if we have some sort of discriminated parameters.Use Cases
Examples
As a callback
As a function expression
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: