-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
ng cli build --prod fails when activating noUnusedParameters in tsconfig.json #4443
Comments
Yeah at some point when TSlint deprecated the Unfortunately the compiler option doesn't seem to be very smart and flexible, so I didn't move ahead with that. In theory we could prefix all those variables with an underscore, but I'm not sure if TypeScript improves their option at some point & if it's worth the efforts. |
Seems like the unused parameter issue also got some attention in the angular core recently angular/angular#15532 Would this solve this issue also or is it just fixing the |
@jelbourn Are you thinking we should prefix those variables with an underscore? And probably compile the AOT demo-app with If I recall correctly there will be a lot of locals and parameters that need to be prefixed with an underscore. |
Other than those two categories I don't think anything should change. |
If we enable // Value is not used. Needs to be prefixed
_onChange = (value: any) => {};
/**
* Sets the vertical placement of the tile in the list.
* This method will be implemented by each type of TileStyler.
* @docs-private
*/
setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number, gutterWidth: number) {} The TypeScript would force us to prefix them with an underscore. Not a big deal, but just want to let you know what will change. |
Function params should not be prefixed with an underscore. If a method is abstract, it should be marked as abstract. For that _onChange: (any?) => void = () => {}; |
Yeah that makes sense. I didn't write the grid-list so I don't know why it isn't made abstract. Most of those |
Yeah, if the generated code doesn't have an issue then a CI check would be necessary. |
I think this is considerably more than a "nice to have". A library like Material should not block people from using strict compiler checks in their projects. |
That priority level mainly comes from the fact that Angular's generated code is the culprit in most cases, which is outside the scope of material. |
* Recently Angular core fixed their `noUnusedParameters` warnings in angular/angular#15532 * When using Angular with Material and the users has `noUnusedParameters` enabled the library will be checked and will throw. Fixes angular#4443
* Recently Angular core fixed their `noUnusedParameters` warnings in angular/angular#15532 * When using Angular with Material and the users has `noUnusedParameters` enabled the library will be checked and will throw. Fixes angular#4443
* Recently Angular core fixed their `noUnusedParameters` warnings in angular/angular#15532 * When using Angular with Material and the users has `noUnusedParameters` enabled the library will be checked and will throw. Fixes angular#4443
* Recently Angular core fixed their `noUnusedParameters` warnings in angular/angular#15532 * When using Angular with Material and the users has `noUnusedParameters` enabled the library will be checked and will throw. Fixes angular#4443
* Recently Angular core fixed their `noUnusedParameters` warnings in angular/angular#15532 * When using Angular with Material and the users has `noUnusedParameters` enabled the library will be checked and will throw. Fixes angular#4443
* Recently Angular core fixed their `noUnusedParameters` warnings in angular/angular#15532 * When using Angular with Material and the users has `noUnusedParameters` enabled the library will be checked and will throw. Fixes #4443
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Bug/Improvement
What is the expected behavior?
Should be able to build with
ng build --prod
when havingcompilerOptions.noUnusedParameters: true
intsconfig.json
What is the current behavior?
Build fails with
What are the steps to reproduce?
ng new my-project
"noUnusedParameters": true
in the projectstsconfig.json
ng build --prod
What is the use-case or motivation for changing an existing behavior?
Apps using material should be able to compile with
noUnusedParameters: true
intsconfig.json
.Which versions of Angular, Material, OS, browsers are affected?
"@angular/animations": "^4.1.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/material": "^2.0.0-beta.3",
"@angular/cli": "1.0.1",
Is there anything else we should know?
Looks like this is some generated code from html templates. I don't know if it's even the fault of angular material.
The fix would be to define parameters with a leading
_
. See microsoft/TypeScript#9860.The text was updated successfully, but these errors were encountered: