microsoft / microsoft/TypeScript

Allow trailing lines in multiline comment directives

Open
#38,370 4 comments 0 reactions 1 assignee View on GitHub

@DanielRosenwasser is already working on this.

Since May 8, 2020.

Bug Domain: Parser Rescheduled
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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 https://github.com/microsoft/TypeScript/pull/38228#discussion_r420940329, as suggested by @sheetalkamat.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.