Skip to content

Allow trailing lines in multiline comment directives #38370

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
JoshuaKGoldberg opened this issue May 6, 2020 · 4 comments
Open

Allow trailing lines in multiline comment directives #38370

JoshuaKGoldberg opened this issue May 6, 2020 · 4 comments
Assignees
Labels
Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@JoshuaKGoldberg
Copy link
Contributor

TypeScript Version: 4.0.0-dev.20200507

Search Terms: multiline comment directive ts-expect-error ts-ignore

Code

const x = 0;

/* @ts-ignore
continuing comment 
 that could be multiline*/

x();

Expected behavior:

The comment looks like a directive to ignore the x();'s type checking complaint.

Actual behavior:

Comment directive parsing only looks at the last line of the comment. It should also allow the first line of the comment.

I'm in favor of not allowing any other lines (i.e. "middle" lines) to count as directives. Extending to allow characters after the @ts- has precedent from what's already allowed (we're really just adding newlines). But putting characters before the @ts- has a precedent of not working even in single-line comments.

/* Here we use a
@ts-ignore
 that is multiline*/

Playground Link: https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=28&pc=2#code/MYewdgzgLgBAHjAvDADAbgFAYPQCoYACUEAtAJYDmYIATgKYahhRlgCurFMoAtj3cxgYYUABYBDWKDYAbACYwARnRg9ZLGazq5sWOAAoAlGiA

Related Issues: Following discussion in #38228 (comment), as suggested by @sheetalkamat.

@sheetalkamat
Copy link
Member

sheetalkamat commented May 6, 2020

@DanielRosenwasser and @RyanCavanaugh should comment on whether @ts-ignore is allowed anywhere in the comment or not but the scenario particularly shows discrepancies is:

    // @ts-ignore
    // come comment
    // some other comment

    // @another

    x(); // This ignores error 

    /* @ts-ignore */
    /*another comment
     that could be multiline*/

    x(); // while this does not ignore error

    /* @ts-ignore */
    // another comment
     // that could be multiline

    x(); // this will ignore the error

    // @ts-ignore
    /*another comment
     that could be multiline*/

    x(); // while this does not ignore error

@DanielRosenwasser
Copy link
Member

Wow,

    // @ts-ignore
    // come comment
    // some other comment

    // @another

    x(); // This ignores error 

Really!?

@sheetalkamat
Copy link
Member

@DanielRosenwasser we have test for that which i only realized when i was looking into #38296 and e860d48 failed for the test

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label May 8, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.0 milestone May 8, 2020
@RyanCavanaugh
Copy link
Member

@DanielRosenwasser Oof. Please come up with some kind of specification on how this should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

5 participants