microsoft / TypeScript

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

Much better comment preservation #38539

Open eco747 opened 4 years ago

eco747 commented 4 years ago

some comments are removed (even even removeComments to false)

TypeScript Version: Version 3.9.1-rc

Search Terms: Much better comment preservation

Code

// my comment 1
import { something } from './somefile.js';
// my comment 2
declare let test1: something;
let test = new something( {} );

// also
let item = [
    // my comment 3
        { a: 0 },
    { a: 0 },
    { a: 0 },
    // my comment 4
];
**Expected behavior:**
// my comment 1
import { something } from './somefile.js';
// my comment 2
let test = new something( {} );

// also
let item = [
    // my comment 3
    { a: 0 },
    { a: 0 },
    { a: 0 },
   // my comment 4
];

Actual behavior:

// my comment 1
import { something }from '/lib/backend/./somefile.js';
let test = new something({});

// also
let item = [
    // my comment 3
    { a: 0 },
    { a: 0 },
    { a: 0 },
];

Related Issues: sound like previous bugs report but not.

1665

16727

eco747 commented 3 years ago

new: with typescript 4.3.5 now generated: // my comment 4 still missing: // my comment 2

I think that declare keyword do not generate anything in JS, so the comment is skipped

actual behaviour

// my comment 1 import { something }from '/lib/backend/./somefile.js'; let test = new something({});

// also let item = [ // my comment 3 { a: 0 }, { a: 0 }, { a: 0 }, // my comment 4 ];