Skip to content

tsc removes comments preceding 'export = ...' unless extra newline follows the comment #6399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ulritech opened this issue Jan 8, 2016 · 0 comments
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@ulritech
Copy link

ulritech commented Jan 8, 2016

The tsc compiler with remove comments set to false (no --removeComments flag and/or "removeComments": false in tsconfig.json) performs unexpectedly based on whitespace characters surrounding comments before an export statement. For example,

/* @ngInject */
export = function($scope: any) {
    // A comment
    $scope.options = {};
}

Run the compiler:

$ tsc --module commonjs controller.ts

The compiler strips /* @ngInject */ but preserves // A comment

module.exports = function ($scope) {
    // A comment
    $scope.options = {};
};

However, *placing a new line after /* @ngInject / keeps it from being removed:

/* @ngInject */

export = function($scope: any) {
    // A comment
    $scope.options = {};
}

produces

/* @ngInject */
export = function($scope: any) {
    // A comment
    $scope.options = {};
}

Any idea why tsc is sensitive to such contextual whitespace?

$ tsc -v
message TS6029: Version 1.7.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

4 participants