-
Notifications
You must be signed in to change notification settings - Fork 6
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
Type for done not inferred #5
Comments
Yeah, that's really bad. It sucks that TypeScript can't handle this because it's a really legitimate use-case. I've run into it on a few other places now (Express.js, Passport.js, etc). Even making the argument optional messes up things more using |
In the Express typings I worked around this by not using a callable interface, but duplicating the definitions and using method overloads instead of using the interface. I don't know though if that would work here - |
Ah I think it never worked, but I just recently activated |
@felixfbecker FWIW, I've never had the Express.js typings work out of the box. Not sure if we're doing something different with them. |
What do you mean with you never had the express typings work out of the box? |
I've never been able to do |
Ah, now I know what youre talking about. It worked when the definition was only get(path: PathArgument, ...handlers: (RequestHandler | RequestHandler[])[]): this but then someone reported that get(path: PathArgument, ...handlers: (RequestHandler | ErrorHandler | (RequestHandler | ErrorHandler)[])[]): this so I sacrificed the inference in types/express#2 |
What to take from this is: Inference does not work when the type is a type alias/interface. |
Should there be an issue open on TS side? |
Probably |
However, if it works as you wanted it to, will it still have the (if I understand correctly on what you want) 🌷 |
The way how
it
is defined as a callableITestDefinition
interface makes it impossible for TS to infer the type of thedone
callback.Doing
yields
This used to work. Now we have to do
The text was updated successfully, but these errors were encountered: