Skip to content
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

Intellisense doesn't work with constant function parameters #7928

Closed
egamma opened this issue Apr 7, 2016 · 5 comments
Closed

Intellisense doesn't work with constant function parameters #7928

egamma opened this issue Apr 7, 2016 · 5 comments
Assignees
Labels
Duplicate An existing issue was already created

Comments

@egamma
Copy link
Member

egamma commented Apr 7, 2016

From @startrekdude on April 5, 2016 23:49

  • VSCode Version: 0.10.11
  • OS Version: Windows 10

Steps to Reproduce:

files.zip

  1. Create a file called SomeAPI.js with the following content:
var SomeAPI = (function () {
   "use strict";  
    var exports = {};

    exports.sayHello = function (name) {
        alert("Hello, " + name);
    }

    return exports;
})();
  1. Create a file called SomeAPI.d.ts with the following content:
declare namespace SomeAPI {
    function sayHello (name: string) => void;
}
  1. Create a file called app.js with the following content:
/// <reference path="./SomeAPI.d.ts"/>
(function (SomeAPI) {
    "use strict";

    var hello = function () {
        SomeAPI.sayHello(document.body); // Oops! No Intellisense!
    }

    document.addEventListener("DOMContentLoaded", hello);
})(SomeAPI); // This one works
  1. Mouse over the line where it says "SomeAPI.sayHello" (in app.js).

Observed Behaviour:
Visual Studio Code's Intellisense informs the user that SomeAPI is of the any type, as is it's child sayHello.

Expected Behaviour:
Visual Studio Code informs the user that SomeAPI is a namespace and that sayHello is a function that takes a string.

Why this bug is important to fix:
Immediately-Invoked Function Expressions were a common way of doing modules and scoping before ES6's (awesome) import statements. There is a lot of legacy code that still uses them.

Copied from original issue: microsoft/vscode#4990

@egamma egamma self-assigned this Apr 7, 2016
@egamma
Copy link
Member Author

egamma commented Apr 7, 2016

Moving to TypeScript for investigation

@DanielRosenwasser
Copy link
Member

@startrekdude your .d.ts file seems incorreclty authored. Did you mean the following?

declare namespace SomeAPI {
    function sayHello(name: string): void;
}

@DanielRosenwasser DanielRosenwasser added the Needs More Info The issue still hasn't been fully clarified label Apr 7, 2016
@startrekdude
Copy link

Indeed. 😄
Here's an updated zip file: files.zip

@michaelmesser
Copy link

Sadly the TS team has decided not to add this feature. See #4142 and #7601.

@DanielRosenwasser DanielRosenwasser added Duplicate An existing issue was already created and removed Needs More Info The issue still hasn't been fully clarified labels Apr 9, 2016
@DanielRosenwasser
Copy link
Member

Reopened #4142.

@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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants