Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unused type parameters should be checked by --noUnusedParameters, not --noUnusedLocals #20568

Closed
mattmccutchen opened this issue Dec 8, 2017 · 1 comment
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@mattmccutchen
Copy link
Contributor

I reviewed the compiler options for my project and decided to enable --noUnusedLocals but not --noUnusedParameters since the cost-benefit picture seems to be much better for --noUnusedLocals. However, I was surprised to get an error on a type alias that has an unused type parameter for documentation purposes. Since "type parameter" has "parameter" in the name, I expected it would be checked by --noUnusedParameters. I see that several issues have been filed related to the check for unused type parameters, but no one seemed to think it was odd that the check was under --noUnusedLocals.

The code change is very simple, and I'll be happy to prepare a pull request if you agree with the change. I suppose it's a breaking change if someone is using --noUnusedParameters and not --noUnusedLocals; that configuration seems unlikely.

TypeScript Version: current master (5e5b770)

Code

// Compile with --noUnusedLocals
type Oops<T> = number;

Expected behavior:
No errors.

Actual behavior:

unused-type-parameter.ts(1,11): error TS6133: 'T' is declared but its value is never read.
@mhegazy
Copy link
Contributor

mhegazy commented Jan 11, 2018

I suppose you are right.. this is a breaking change technically. but open to taking a PR.

@mhegazy mhegazy added Bug A bug in TypeScript Help Wanted You can do this Breaking Change Would introduce errors in existing code labels Jan 11, 2018
@mhegazy mhegazy added this to the Community milestone Jan 11, 2018
mattmccutchen added a commit to mattmccutchen/TypeScript that referenced this issue Jan 12, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 26, 2018
@mhegazy mhegazy modified the milestones: Community, TypeScript 2.8 Jan 26, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

2 participants