-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
From @Cow258 on April 17, 2018 3:21
I am doing a class library and some function like jQuery.each().
I am trying to define [this] in callback function.
But it doesn't work...
Input code
/**
* @this {Car}
* @type {function(Car):boolean}
*/
var callback_tips = function () { }
var Cars = [];
class Car {
constructor(name) { this.name = name; this.x = 0; }
Forward(step) { this.x += step; }
/** @param {callback_tips} callback */
static Each(callback) {
for (let car of Cars) { callback.apply(car, car); }
}
}
(function main() {
Cars = [new Car('A'), new Car('B'), new Car('C')];
console.log(Cars);
// <!-- BUG HERE
Car.Each(function (car) { this.name += this.name; this.Forward(5); });
// BUG HERE -->
console.log(Cars);
})();Debug output
[ Car { name: 'A', x: 0 }, Car { name: 'B', x: 0 }, Car { name: 'C', x: 0 } ]
[ Car { name: 'AA', x: 5 }, Car { name: 'BB', x: 5 }, Car { name: 'CC', x: 5 } ]JSDoc configuration
Default VSCode configuration
Expected behavior
Showing up tips about Car class when typing [this].

Current behavior
Bug? callback -> this -> *:any .
Normal callback tips is working .
.
But [this] do not work .

My environment
| Software | Version |
|---|---|
| VSCode | 1.22 (March 2018) |
| JSDoc | ??? |
| Node.js | 9.10.1 |
| npm | 5.6.0 |
| Operating system | MacOS 10.12.6 |
Copied from original issue: microsoft/vscode#48021
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created