Microsoft/TypeScript

ts-expect-error is reported as unused on rootDir error

開放

#48,850 建立於 2022年4月26日

 (3 則留言) (0 個反應) (0 位負責人)TypeScript (13,395 個分叉)batch import
BugDomain: Something ElseEffort: ModerateHelp Wanted

倉庫指標

星標
 (108,860 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Bug Report

Minimal reprod repo.

ts-expect-error cannot be used to silent a ts(6059, rootDir not containing all the files) error.

with directive without directive

🔎 Search Terms

ts-expect-error, rootDir, 6059

🕗 Version & Regression Information

TypeScript 4.6.3.

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because this involves tsconfig.json.

⏯ Playground Link

https://github.com/proteriax/ts-expect-error-bug

💻 Code

See reprod repo above.

// We can quickly address your report if:
//  - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!
//  - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.
//  - The incorrectness of the behavior is readily apparent from reading the sample.
// Reports are slower to investigate if:
//  - We have to pare too much extraneous code.
//  - We have to clone a large repo and validate that the problem isn't elsewhere.
//  - The sample is confusing or doesn't clearly demonstrate what's wrong.

🙁 Actual behavior

The error goes away with a // @ts-expect-error above it.

🙂 Expected behavior

See screenshot above. If you have the directive, TypeScript thinks it’s useless; if you don’t, TypeScript will give you an error.

貢獻者指南