Microsoft/TypeScript

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

Open

#48,850 创建于 2022年4月26日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: Something ElseEffort: ModerateHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 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.

贡献者指南