添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
年轻有为的熊猫  ·  GitHub - ...·  2 月前    · 
可爱的伏特加  ·  Control — Godot ...·  7 月前    · 
千年单身的油条  ·  JIRA throws exception ...·  1 年前    · 

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

This is related but more general: #13408

Suggestion

This ts.Diagnostic message is classified as an Error not a warning:

    "'{0}' is declared but its value is never read.": {
        "category": "Error",
        "code": 6133,
        "reportsUnnecessary": true

Examples

Suppose someone is writing new code and not quite finished yet.

const x: number = 123;
const y: number = 321;
const product: number = x*y;
// TODO: Do something with "product"

They have not used x yet, but they certainly plan to use it when they are done writing their code. When you run tsc the output looks like this:

src/index.ts:9:5 - error TS6133: 'x' is declared but its value is never read.

With a professional build orchestrator, this "compiler error" will:

  • be printed in bright red, distracting attention from legitimate errors (e.g. calling a function that is not defined)
  • prevent downstream dependency projects from building
  • possibly also prevent other tasks (e.g. Jest) from running for the current project (we don't run tests if the code doesn't compile)
  • Proposal: Make it a warning instead:

        "'{0}' is declared but its value is never read.": {
            "category": "Warning",
            "code": 6133,
            "reportsUnnecessary": true
    

    Checklist

    My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
  •