-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Intellisense is not able to infer types for function parameters #11155
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
Comments
@LasTshaMAN thank you for opening this issue and for sharing your code. I have reproduced this issue with the latest VS Code version and the TS 2.0.5. Because this functionality is provided by TypeScript language service I am migrating the issue to their repository. |
@LasTshaMAN what makes you believe this is a compiler or tools bugs rather than an issue with the express declaration file? |
@mhegazy, I believe this is the issue with VS Code and not with the compiler or the express file declaration, because I get reasonable hints in Webstorm IDE as shown at the screen below: I guess I should have attached such a screen to my original post. |
WebStorm uses a different implementation to get you hints. i really have no insight into what they do. VSCode uses the ts compiler and services. if VSCode things this now the type of |
Here are express type definitions as downloaded by typings tool. I believe that express type definitions file is Ok, I can trace my "req" and "res" params to the definition of RequestHandler: Although, I'm quite new to Typescript and don't quite get why I'm able to leave out non-optional "next" parameter here. |
Although such a type inference (we are talking about here) works in case of another library in VS Code, say "request" library. By the way, the situation described above is reproducible even on the latest version of "express" typescript. Which leads me to think that the problem is either with typescript definition file or it is with the tooling VS Code uses to infer types (may be it is not powerful enough to trace 3-4 references). |
this looks to be the same underlying issue as in #11875. the overload resolution algorithm does not really support overload on arity, which seems to be what express is using here. |
From @LasTshaMAN on September 24, 2016 22:53
Steps to Reproduce:
Take a look at the screenshot:
Once you add types for "req" and "res" parameters explicitly Intellisense works just fine.
Here is Github link for my project, if you want to reproduce this behavior fast.
By the way, enjoying working with VS Code, you did a great job, guys!
Copied from original issue: microsoft/vscode#12565
The text was updated successfully, but these errors were encountered: