question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decorated private propoerty flagged as unused with `noUnusedLocals:true`

See original GitHub issue

noUnusedLocals:true

import { Component } from '@angular/core';

@Component({
  selector: 'my-component',
  template: `
    {{text}}
  `,
})
export class MyComponent {
  @Input()
  private text: string;//'text' is declared but never used
}

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:11
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
andruicommented, Dec 27, 2016

The problem is really annoying for angular projects. Especially for re-usable components lib when some properties/methods should be private, but they are called only from component’s template. This causes “unused local” error for such a methods/variables. So, if there is no possibility to check templates then the best solution is to introduce some “ignore” comment to avoid compiler errors in such a cases.

4reactions
aluanhaddadcommented, Dec 27, 2016

@andrui Just remember that if you ever try to use the angular AOT compiler, which is essentially a subset of typescript, all of your private fields used in template bindings will cause compilation errors and you have to rewrite your code.

This is off topic, since it isn’t typescript at all at that point, but I thought I’d mention it since it seems to nullify the use case for many users.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Decorated private propoerty flagged as unused with ... - GitHub
I believe that this is almost impossible to predict all template usage (if we are talking not only about decorated properties/functions).
Read more >
"parserOptions.project" has been set for @typescript-eslint ...
I've been trying to integrate eslint with typescript but it doesn't seem to recognize files under the src folder even though I listed...
Read more >
noUnusedLocals - TSConfig Option - TypeScript
How this setting affects your build.
Read more >
Ask Question
"noUnusedLocals": true, /* Enable error reporting when a local variables ... using the 'esModuleInterop' flag 3 import BN from 'bn.js';.
Read more >
Overview - TypeScript
Additionally, TypeScript 3.4 introduced the --incremental flag for saving ... each constituent of T has a done property that's specifically true or false...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found