Skip to content

comments before imports are stripped in AMD output unless there's a blank line after them #26079

@dgoldstein0

Description

@dgoldstein0

TypeScript Version: 3.0.1

Search Terms: preserve comments removes comments

Code
Compile the following with --module amd

// foo
import 'foo';

console.log('hi');

Expected behavior:
output contains // foo

Actual behavior:
output does not contain // foo.

If a newline is added between // foo and the import 'foo', the comment will then show up in the output. If the file is compiled with --module commonjs, the comment will also show up in the output, in that case regardless of the whitespace.

Playground Link: https://www.typescriptlang.org/play/#src=%2F%2F%20foo%0D%0Aimport%20'foo'%3B%0D%0A%0D%0Aconsole.log('hi')%3B%0D%0A

Related Issues: this looks most similar to #6399

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Comment EmitThe issue relates to the emission of comments when compiling

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions