microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.76k stars 12.46k forks source link

Missing comments after applying refactor/codefix #29972

Open gabritto opened 5 years ago

gabritto commented 5 years ago

TypeScript Version: 3.4.0-dev.201xxxxx

Search Terms: missing comment

Several refactors and codefixes cause comments in some positions to disappear after being applied.

Code

const a = (a: number) => {/* missing */ return a; /* missing */};
const b = (a: number) => { /* missing */
    return a; /* missing */
}

Code

class A { // missing
    a(s: string) { // missing
        return s;
    }
}

Code

namespace Extract {
    class B { // missing
        a(s: string) { // missing
            return s;
        }
    }
}

Code

type K = "foo" | "bar";
interface SomeType { /*missing*/
    a: string;
    /*missing*/ [prop: K] /*missing*/: any;
}

Code

function fn(a: /*missing*/ ?number) {
    return a;
}

Code

function fun(b) { // missing
    this.b = b;
}
exports.f /*missing*/ = /*missing*/ function() { };
// @ts-check
class C {
    constructor() {/*missing*/
        //missing
    }
    prop = ()=>{ this.foo === 10 };
}

Expected behavior: Comments should be present after applying refactor/codefix. Actual behavior: Comments are missing after refactor/codefix.

jsjoeio commented 4 years ago

May I take this?

andrewbranch commented 3 years ago

Move to new file:

export const enum CharCode {
    "/" = 47, // missing
    "a" = 48,
}