-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
Only warn for unused functions and imports during development #45043
Comments
See https://www.typescriptlang.org/tsconfig#extends for how to easily configure separate "development" and "production" compiles. |
Or maybe it sounds like you're asking for something to flag unused imports, separately from the dev/prod distinction? There are lint rules you can enable for those already, which fits your criteria well |
Hey @RyanCavanaugh , The error that is spit out at least when I have an unused function is "TS6133". In my opinion it should be configurable if it is a warning or a hard error. As hard error it is just really really annoying during development. |
If you have separate configs, why isn't your dev config set up to ignore unused imports? Isn't that the request?
There's no warning/error distinction anywhere in TypeScript. |
@RyanCavanaugh |
There isn't a TS setting for this (see #30517), but it can be detected by a syntactic linter |
I dont want to detect dead exports though. On the contrary. I dont want the typescript compiler to throw an error on an unsused import or if the file has an unused function. In the example I gave:
The compiler would throw an error that |
The behavior you're describing here is |
@RyanCavanaugh ,
tsconfig.app.json
|
TS does not issue the "Failed to compile" message; this indicates you're using a third-party build tool which would need to provide functionality for disregarding the tsc error code |
True, I use angular. |
For anyone stumbling over it as I did, set following configurations:
Thanks @RyanCavanaugh for bearing with me! |
Suggestion
π Search Terms
allow unused imports, allow unused functions
β Viability Checklist
My suggestion meets these guidelines:
β 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
π» Use Cases
The text was updated successfully, but these errors were encountered: