-
Notifications
You must be signed in to change notification settings - Fork 888
no-unused-variable function called from the view Angular 2. #1295
Comments
Checking a template file for references feels out-of-scope for TSLint because we rely on TypeScript's Language Service APIs for finding occurrences of values. I don't think TSLint will do this unless the LS does static analysis of templates (there is some hope for this; see microsoft/TypeScript#3003 and microsoft/TypeScript#5151). In the meantime, your workarounds are to use the |
Thats what I suspected, but wanted to make sure. Also relates to Microsoft/Typescript#5470 . Thanks! |
Going to close this because it's not actionable on the TSLint side of things. As always, more discussion is always welcome and if thing change in the future on the TS side of things we can see what we can do in TSLint as well |
I think |
@alexeagle this still true?! Thank you... |
Still true. The template is not part of the class, with AoT compilation it is a separate class. So they can't be private. |
This is still not working with Angular2 Final and latest tslint (3.15.1). We have private template variables. Should we now make them all public ? |
Having tslint look into Angular templates is complex. To do it right, we really need to use Angular's template expression parser to get 100% compatibility, then hook Angular as an extension in TypeScript language service. We are close to a first version of VSCode support for angular templates. I'd like to figure out the linting story soon after. |
For anyone else reading this you can mark the methods as "protected" and the error goes away, but you're not exposing the method outside the class 👍 |
I don't see why `protected` is helpful, you'll still get a type-check error
from the generated .ngfactory.ts file right?
…On Tue, Jan 31, 2017 at 1:59 AM franz ***@***.***> wrote:
For anyone else reading this you can mark the methods as "protected" and
the error goes away, but you're not exposing the method outside the class
👍
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1295 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC5IxoPQbJmhHUaCVU4Ow8BoQzVSl9Hks5rXwYZgaJpZM4Iw1J3>
.
|
I couldn't say @alexeagle - to be honest I'm using the ionic2 CLI which was giving the same issue. I would imagine it would solve the same issue .. it's all TypeScript under the hood. I'm figuring tslint thinks the class may be inherited elsewhere (like a public modifier) and therefore doesn't flag it? In essence making my methods (that are referenced in the template) no longer error when they're protected :) |
Bug Report? Question
3.10.2
1.8.10
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
reported as an unused variable
Expected behavior
Could it check specified view file?
solved by prefixin with on but seems like there should be some better solution but have no Idea what....
The text was updated successfully, but these errors were encountered: