Skip to content

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

Closed
@jednano

Description

@jednano

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

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions