Skip to content

ts-expect-error comment expects more than one error #38289

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

Closed
jednano opened this issue May 1, 2020 · 0 comments · Fixed by #38296
Closed

ts-expect-error comment expects more than one error #38289

jednano opened this issue May 1, 2020 · 0 comments · Fixed by #38296
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@jednano
Copy link
Contributor

jednano commented May 1, 2020

TypeScript Version: 3.9.1-rc

Search Terms:

ts-expect-error comment expects more than one error multiple lines

Code

// @ts-expect-error
(({ a: true } as const).a === false); // <-- compiles (as expected via comment)
(({ a: true } as const).a === false); // <-- compiles, expected an error though

(({ a: true } as const).a === false); // error (as I would expect)

(({ a: true } as const).a === false); // error (as I would expect)

Expected behavior:

I only expect // @ts-expect-error to ignore a single error at a time.

Actual behavior:

The // @ts-expect-error comment expected two errors spanning across two separate lines. The comment seems to take empty lines into account as a separator? Quite odd, seeing as code should ignore whitespace.

Work-around:

Add an empty line between the expected error line and the one that follows.

Playground Link:

https://www.typescriptlang.org/play/index.html?ts=4.0.0-dev.20200430#code/PTAEAEBcGcFoFMAeAHeBjSCBOWD2WAoACiIG9QBDALlEiwFd5QBfS6UNXAO2kgEoAdBVABeMaABmFADbR4fANzEylGnUYs2Hbr0HCxIyTLmKCy8tVoMmrCu049+Q0eKmz5S86qsbb9nU76rsYeBEA

Related Issues:

Couldn't find any.

Screen Shot 2020-05-01 at 10 41 22 AM

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label May 1, 2020
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.9.2 milestone May 1, 2020
@sheetalkamat sheetalkamat added the Fix Available A PR has been opened for this issue label May 1, 2020
typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this issue May 1, 2020
Component commits:
168be30 Fix incorrect line text computation to stop comment directive searching Fixes microsoft#38289
typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this issue May 1, 2020
Component commits:
168be30 Fix incorrect line text computation to stop comment directive searching Fixes microsoft#38289

e860d48 Stop searching for comment directive if the previous line is not empty
typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this issue May 4, 2020
Component commits:
168be30 Fix incorrect line text computation to stop comment directive searching Fixes microsoft#38289
sheetalkamat added a commit that referenced this issue May 4, 2020
Component commits:
168be30 Fix incorrect line text computation to stop comment directive searching Fixes #38289

Co-authored-by: Sheetal Nandi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants