vscode icon indicating copy to clipboard operation
vscode copied to clipboard

JSDoc Intellisense not working as shown in release notes (10.10)

Open AdamAndersonFalafelSoftware opened this issue 10 years ago • 15 comments

My intellisense is not showing the same behavior as what's shown in the v10.10 release notes. Note here how the @constructor directive is visible at the end of the description, suggesting that perhaps it wasn't parsed. image

The name parameter does not show the description, but the type is displayed correctly. image

There is no intellisense for the greet function image

Do I need to do something to explicitly enable the functionality showcased in the release notes? I tried executing "Reload Javascript Project" both with and without a jsconfig.json file present already.

I have come across a similar issue.

Intellisense will work as described (in the release notes) with a function declaration:

/**
 * Transform a string to upper-case.
 * @param {string} value The string to be transformed.
 * @returns {string} The upper-cased string.
 */
function upper1(value) {
    return value.toUpperCase();
}

But will be limited (see previous comment be @egamma) with a function expression:

/**
 * Transform a string to upper-case.
 * @param {string} value The string to be transformed.
 * @returns {string} The upper-cased string.
 */
var upper2 = function(value) {
    return value.toUpperCase();
};

My preferred ES2015 style behaves the same:

/**
 * Transform a string to upper-case.
 * @param {string} value The string to be transformed.
 * @returns {string} The upper-cased string.
 */
const upper3 = (value) => {
    return value.toUpperCase();
};

Also, it looks to me that @returns is not being parsed, or perhaps it's just being poorly presented.

LittleBrainz avatar Mar 09 '16 18:03 LittleBrainz

@AdamAndersonFalafelSoftware

My setup is a folder with a single .js file, no jsconfig.json

The name parameter does not show the description, but the type is displayed correctly.

works for me:

image

There is no intellisense for the greet function

works for me:

image

This is the full source

/**
 * Represents a person
 * @constructor
 * @param {string} name The name of the person
 */
function Person(name) {
    this.name = name;
}

/**
 * Greets the person
 * @param {string} greeting The greeting
 */
Person.prototype.greet = function greet(greeting) {
    return greeting + ' ' + this.name;
}

var p = new Person('joe');

egamma avatar Mar 16 '16 14:03 egamma

@LittleBrainz

I've tried the following source

/**
 * To upper case
 * @param {string} value The string to be transformed
 */
function upper(value) {
    return value
}

/**
 * To upper case
 * @param {string} value The string to be transformed
 */
var upper2 = function(value) {
    return value
}

/**
 * To upper case
 * @param {string} value The string to be transformed
 */
var upper3 = (value) => {
    return value
}

And I get proper IntelliSense, parameter hints, hovering. What am I missing?

egamma avatar Mar 16 '16 14:03 egamma

@egamma I can effortlessly reproduce my results in a single .js file all alone in a folder with no jsconfig.json. With your code. Is there anything I can do to help you reproduce my results? Are there any configuration options I need to check in my environment? Perhaps this is an artifact of upgrading from an earlier version of VSCode. Is it possible that somehow I'm not even using Salsa even though it's supposed to be the default now?

@egamma Perhaps this has something to do with it? I just noticed all these errors after opening my user settings. Pretty sure they didn't appear before then. Note that the errors are occurring in a TypeScript server directory.

image

@AdamAndersonFalafelSoftware The screenshot from you above shows that you are using Salsa. Did you anything with the typescript.tsdk setting? It could be that the tsdk points to an older version of Salsa/TypeScript.

I've also tested on 0.10.11 and I cannot reproduce it.

The screenshot above looks like a duplicate of #3766 and I don't think it is related.

egamma avatar Mar 16 '16 14:03 egamma

@egamma I wonder if my TypeScript config is correct. Here are my default settings. Is the tsdk supposed to be null?

image

I just re-tested a few things and got some of the results you did, but not all.

Intellisense for Person appends the @constructor directive to the description: image

I do see intellisense for the name parameter of the constructor: image

I do see the description for Person.prototype.greet: image

,,.but I do not see intellisense for the greeting parameter of Person.prototype.greet: image

@egamma

/**
 * Transform a string to upper-case.
 * @param {string} value The string to be transformed.
 * @returns {string} The upper-cased string.
 */
function upper1(value) {
    return value.toUpperCase();
}


/**
 * Transform a string to upper-case.
 * @param {string} value The string to be transformed.
 * @returns {string} The upper-cased string.
 */
var upper2 = function(value) {
    return value.toUpperCase();
};


/**
 * Transform a string to upper-case.
 * @param {string} value The string to be transformed.
 * @returns {string} The upper-cased string.
 */
const upper3 = (value) => {
    return value.toUpperCase();
};


var v1 = upper1('hey');

var v2 = upper2('ho');

var v3 = upper3('lets go');

Intellisense with a function declaration (upper1)... fd completion And hover... fd hover

Intellisense with a function expression (upper2 & upper3)... fe completion And hover... fe hover

This is VS Code 0.10.11 with a jsconfig.json.

LittleBrainz avatar Mar 16 '16 18:03 LittleBrainz

@AdamAndersonFalafelSoftware

I wonder if my TypeScript config is correct. Here are my default settings. Is the tsdk supposed to be null?

This is the default value that gets inserted, it is treated as the setting is not defined. So I would just delete it.

We have updated to a new version of salsa/typescript 1.8.9 which has additional fixes. We will make this available on the insider channel next Monday.

I suggest to retest there again.

egamma avatar Mar 18 '16 08:03 egamma

@LittleBrainz same here I suggest to retest on the latest with TypeScript 1.8.9.

egamma avatar Mar 18 '16 08:03 egamma

@egamma I am not on the insider channel. How do I join?

@egamma - TypeScript 1.8.9 is giving the same results as 1.8.2. typescript version

LittleBrainz avatar Mar 18 '16 16:03 LittleBrainz

@AdamAndersonFalafelSoftware here is how to get the insiders build https://code.visualstudio.com/blogs/2016/02/01/introducing_insiders_build, but this one doesn't have 1.8.9 yet. To try out 1.8.9 you have to do the same as @LittleBrainz and use the tsdk option to use 1.8.9.

@LittleBrainz in this case I don't see how VS Code could be the culprit. Can you extract the good steps from https://github.com/Microsoft/vscode/issues/3842#issuecomment-197484962 and file an issue against TypeScript.

egamma avatar Mar 18 '16 16:03 egamma

@AdamAndersonFalafelSoftware - TypeScript 1.8.9 is the current default on NPM.

  • Install TypeScript 1.8.9 globally with:
npm install --global typescript
  • On the File menu / Preferences / User Settings, edit the settings.json file to set typescript.tsdk to the folder path containing the tsserver and lib*.d.ts files to use. On my system I have:
"typescript.tsdk": "C:/Users/Stephen/AppData/Roaming/npm/node_modules/typescript/lib"

That should do it. But, be warned, the next version of VS Code may have a more up-to-date TypeScript, so you will have to comment out the line in User Settings when you upgrade next.

LittleBrainz avatar Mar 18 '16 16:03 LittleBrainz

Closing this issue since it is now tracked in the TypeScript repository.

egamma avatar Apr 17 '16 16:04 egamma