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

JavaScript Property Suggestions Do not Pick Up Type From JSDoc Comment #13333

Closed
mjbvz opened this issue Jan 6, 2017 · 4 comments
Closed

JavaScript Property Suggestions Do not Pick Up Type From JSDoc Comment #13333

mjbvz opened this issue Jan 6, 2017 · 4 comments
Labels
Bug A bug in TypeScript Domain: JavaScript The issue relates to JavaScript specifically VS Code Tracked There is a VS Code equivalent to this issue
Milestone

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jan 6, 2017

From @mohsen1 on January 5, 2017 18:28

  • VSCode Version: 1.8.1
  • OS Version: macOS

Steps to Reproduce:

  1. Make a file with following contents
var webpack = require('webpack')

/** @type {webpack.Configuration} */
var config = {
    module: {
        loa // expected autocomplete 
    }
}

module.exports = config;
  1. In line 6, based on webpak type definition I should autocomplete for loaders.

screen shot 2017-01-05 at 10 26 04 am

Copied from original issue: microsoft/vscode#18184

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 6, 2017

Looks like a TS issue, unrelated to webpack and imports. Tested with 2.1.5 and 2.2.0-dev.20170106

Here's a simpler repo:

interface IFoo {
    bar: number
}

/** @type {IFoo} */
const foo = {
    
}

When typing inside of foo, we do not get a completion item for bar. If the code is changed to

interface IFoo {
    bar: number
}

const foo: IFoo = {
    
}

then bar is returned as a completion inside of foo.

Here's the TSServer communications in the bad case:

[Trace - 2:47:42 PM] Sending request: completions (1960). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/sand/bla.ts",
    "line": 7,
    "offset": 5
}
[Trace - 2:47:42 PM] Response received: completions (1960). Request took 1 ms. Success: false . Message: No content available.

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Jan 6, 2017
@mjbvz mjbvz changed the title Automatic type acquisition autocomplete is not working with JSDoc comments JavaScript Property Suggestions Do not Pick Up Type From JSDoc Comment Jan 12, 2017
@mhegazy mhegazy added the Salsa label Feb 18, 2017
@mhegazy mhegazy added the Bug A bug in TypeScript label Feb 18, 2017
@mhegazy mhegazy added this to the TypeScript 2.3 milestone Feb 18, 2017
@mhegazy mhegazy modified the milestones: TypeScript 2.3, Future Mar 24, 2017
@weswigham weswigham added Domain: JavaScript The issue relates to JavaScript specifically and removed Salsa labels Nov 29, 2018
@Sayan751
Copy link

Ran into similar problem, and just wanted to point out that I have imported types as follows. And this (workaround?) works pretty well in vscode v1.35.0-insider.

const HtmlWebpackPlugin = require('html-webpack-plugin');
const baseUrl = "/";

/** @type {() => import("webpack").Configuration} */
module.exports = () => ({
    plugins: [
        new HtmlWebpackPlugin({
            template: "index.ejs",
            metadata: { baseUrl }
        })
    ]
})

@mohsen1
Copy link
Contributor

mohsen1 commented May 29, 2019

Yes the import("webpack").Configuration syntax works now.

@sandersn sandersn removed their assignment Jan 7, 2020
@johnbillion
Copy link

This appears to work as expected now using a standard JSDoc comment for the type of the config object. With the following code I get intellisense for its properties:

const webpack = require('webpack');

/** @type {webpack.Configuration} */
module.exports = {
  ...
};

Screenshot:

Using VS Code 1.45.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: JavaScript The issue relates to JavaScript specifically VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

8 participants