Skip to content

Only warn for unused functions and imports during developmentΒ #45043

Closed
@tdymel

Description

@tdymel

Suggestion

πŸ” Search Terms

allow unused imports, allow unused functions

βœ… Viability Checklist

My suggestion meets these guidelines:

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

⭐ Suggestion

I, as developer, dont want to be constantly annoyed by the compiler exciting because I uncommented some function while debugging code, such that it became unused.

Ideally I would like the compiler to spit out warning during development and spit out errors during production compile.
I can also imagine to add compiler options such as "allowUnusedImport" and "allowUnusedFunction". Currently only unused Variables and parameters are supported.

πŸ“ƒ Motivating Example

function debuggedFunction(): void {
   ... some code ...
   // someFunctionIBrieflyWantToCommentOut();
   ... some code ...
}

private someFunctionIBrieflyWantToCommentOut(): void {
   ... some code ...
}

πŸ’» Use Cases

  • Development
  • Debugging

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions