Skip to content

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

Closed
waderyan opened this issue Sep 26, 2016 · 7 comments
Closed

Intellisense is not able to infer types for function parameters #11155

waderyan opened this issue Sep 26, 2016 · 7 comments
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed VS Code Tracked There is a VS Code equivalent to this issue

Comments

@waderyan
Copy link

From @LasTshaMAN on September 24, 2016 22:53

  • VSCode Version: 1.5.3
  • OS Version: Windows 8.1 x64

Steps to Reproduce:

  1. When I register a request handler with express (without specifying the types of handler function parameters), VS Code can't get me Intellisense to work with these parameters.
    Take a look at the screenshot:

image

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

@waderyan waderyan self-assigned this Sep 26, 2016
@waderyan
Copy link
Author

@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.

@waderyan waderyan added VS Code Tracked There is a VS Code equivalent to this issue and removed typescript labels Sep 26, 2016
@waderyan waderyan removed their assignment Sep 26, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Sep 26, 2016

@LasTshaMAN what makes you believe this is a compiler or tools bugs rather than an issue with the express declaration file?

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Sep 26, 2016
@LasTshaMAN
Copy link

@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:

image

I guess I should have attached such a screen to my original post.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 27, 2016

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 req is any, then this is what the TS compiler thinks of it.

now the type of req is a contextual type comming from express. so looks like express declaration file needs updates.

@LasTshaMAN
Copy link

LasTshaMAN commented Sep 27, 2016

Here are express type definitions as downloaded by typings tool.
download link - sorry, but I didn't manage to upload .zip right into the comment for some reason.

I believe that express type definitions file is Ok, I can trace my "req" and "res" params to the definition of RequestHandler:

image

Although, I'm quite new to Typescript and don't quite get why I'm able to leave out non-optional "next" parameter here.

@LasTshaMAN
Copy link

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.

image

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).

@waderyan waderyan removed the Needs More Info The issue still hasn't been fully clarified label Nov 21, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Dec 15, 2016

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.

@mhegazy mhegazy added the Design Limitation Constraints of the existing architecture prevent this from being fixed label Dec 15, 2016
@mhegazy mhegazy closed this as completed Aug 29, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

3 participants