Skip to content
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

Can I disable noUnusedLocals, noUnusedParameters per file #12913

Closed
seangwright opened this issue Dec 14, 2016 · 6 comments
Closed

Can I disable noUnusedLocals, noUnusedParameters per file #12913

seangwright opened this issue Dec 14, 2016 · 6 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@seangwright
Copy link

TypeScript Version: 2.0.10

After reading about the deprecation of no-unused-variable in tslint v4 I started using noUnusedLocals and noUnusedParameters in my tsconfig.json.

With tslint I can disable a rule for a file or line

/* tslint:disable:no-unused-variable */
// tslint:disable-next-line

Is this disabling possible if Typescript is performing the checks?

Here is a stackoverflow question related to this http://stackoverflow.com/questions/38237594/pragma-disable-for-nounusedlocals

Thanks

@RyanCavanaugh
Copy link
Member

No. See also #11051

@thw0rted
Copy link

So uh, would a feature request for this capability be a new ticket then? As I just commented on #11051, I'm working with generated TS (transpiled from Java with jsweet) and I'm not sure they will be able to totally avoid generating unused / unreferenced vars.

@ghost
Copy link

ghost commented May 16, 2018

@thw0rted I'm in a similar situation with another TypeScript generator but I think #11051 has the solution. If I rename the generated type file to *.d.ts it is ignored during noUnusedLocals and noUnusedParameters. Unfortunately the generator refuses to generate anything other than a .ts extension, so I have to rename at another point in my build process, but it works.

@thw0rted
Copy link

I don't think that's going to help me, I'm not generating typings but actual implementations, and .d.ts is always an ambient context (right?).

This is a frustrating issue, because it's a basic feature that just about every other tool I can think of includes. If you're going to warn me about something that doesn't impact program execution (like noUnusedParameters etc) then, on a case-by-case basis, I need to be able to tell the tool that I know better and in this one specific instance, it's correct, even though you think it might be a problem.

@RyanCavanaugh
Copy link
Member

@thw0rted // @ts-ignore

@thw0rted
Copy link

That's a good point -- if it's too much to ask the generator to never create an unused local, maybe we can at least identify the cases where the local might be unused and give them an ignore directive preemptively.

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants