Skip to content

tsc with no comment flags remove some comments. #13602

@mxtopher

Description

@mxtopher

TypeScript Version: 2.1.5

Code

class Promise {
    then(callback:any){};
};

function commentedPromise(){
    new Promise()
    /* Commented Promise */.then(function(){});
}

function commentedParameters(
/* Parameter a */
a
/* End of parameter a */
/* Parameter b */
,
b
/* End of parameter b */
){}

Expected behavior:

This should be the compiled version:

var Promise = (function () {
    function Promise() {
    }
    Promise.prototype.then = function (callback) { };
    ;
    return Promise;
}());
;
function commentedPromise() {
    new Promise()
        /* Commented Promise */.then(function () { });
}
function commentedParameters(
/* Parameter a */
a
/* End of parameter a */
/* Parameter b */
,
b
/* End of parameter b */
) { }

Actual behavior:

This is what I get

var Promise = (function () {
    function Promise() {
    }
    Promise.prototype.then = function (callback) { };
    ;
    return Promise;
}());
;
function commentedPromise() {
    new Promise()
        .then(function () { });
}
function commentedParameters(
    /* Parameter a */
    a, b) { }

I agree these comments are in very weird positions, but I have a custom build system which uses /#IFDEF/ style guards, and I'm migrating a codebase with some hundreds of them.

Typescript is stripping some of these comments without warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions