microsoft / microsoft/TypeScript

Head comments are removed in some cases for next `import` line

Open
#39,520 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: Comment Emit Needs Human Review
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description


name: Bug
about: Create a report to help us improve TypeScript
title: 'Head comments are removed in some cases'
labels: ''
assignees: ''


TypeScript Version: 3.7.x-dev.201xxxxx

There is a repo, the same result for 3.6 and latest next 4.0...

Search Terms:

Code

// @some-comment
import { A } from "./mod";

const a: A = {};

Repro repo: https://github.com/whitecolor/ts-remove-comment-import

Expected behavior:

Comments is not removed

"use strict";
// @some-comment
Object.defineProperty(exports, "__esModule", { value: true });
var a = {};

Actual behavior:

Head comments are removed in some cases for next import line. Produced output:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var a = {};

Playground Link:

No.

Related Issues:

Yes. There were a few alike issues before.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the reproduction repository linked in the issue and compile the shown TypeScript example with the affected TypeScript versions. Compare the emitted JavaScript with the expected output, focusing on preservation of the head comment before the import. Done means the comment remains in the generated output for the reported cases and existing related behavior is not regressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.