Skip to content

Convert To ES6 Class Refactoring Loses JSDocs on Methods #16622

@mjbvz

Description

@mjbvz

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)

Code

function Wagon(numberOxen) {
    this.numberOxen = numberOxen
}

/**
 * Continue traveling to Oregon
 * @param {number} speed How fast to travel. Should be > 0 and < c
 */
Wagon.prototype.go = function(speed) { }

new Wagon(1)

Trigger the convert to es6 class refactoring on Wagon

Expected behavior:

JSDoc on go is preserved in the new class

class Wagon {
    constructor(numberOxen) {
        this.numberOxen = numberOxen;
    }
    /**
     * Continue traveling to Oregon
     * @param {number} speed How fast to travel. Should be > 0 and < c
     */
    go(speed) { }
}

new Wagon(1)

Actual behavior:
JSdoc is lost:

class Wagon {
    constructor(numberOxen) {
        this.numberOxen = numberOxen;
    }
    go(speed) { }
}

new Wagon(1)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbolFixedA PR has been merged for this issueVS Code TrackedThere is a VS Code equivalent to this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions