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.

noUnusedLocals reporting warnings for properties used in <template>

See original GitHub issue
  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: macOS
  • Vetur version: 0.19.2
  • VS Code version: 1.33.1 (1.33.1)

Problem

With noUnusedLocals on, Vetur is report “declared but never read” errors for properties used in the <template> in single file components. See how msg is used in line 3 in the screenshot below: Screenshot 2019-04-30 at 15 34 53

Reproducible Case

https://github.com/jwhitmarsh/vetur-no-unused-locals

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
octrefcommented, Apr 30, 2019

Let’s keep it open since template part should ideally be considered the same file as the SFC. Now we have a temporary workaround https://github.com/vuejs/vetur/pull/1243 but that’s not a good long-term solution.

1reaction
jwhitmarshcommented, Apr 30, 2019

Ah I didn’t realise it was the private keyword that was causing the issue. Just FYI the screenshot above (and the example repo) is what is generated by the Vue CLI (if you chose the TypeScript settings), which is why I didn’t think to change the private keyword.

I’ll mark this as closed, but I wonder if there’s a good place to document this as I imagine it’ll affect anyone creating a new app with Vue CLI running Vetur. To add to that, the reason I turned on noUnusedLocals was following the advice in #1063 so this might come up more as people move to a TS version that supports the flag.

Thanks all for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

tslint how to disable error "someVariable is declared but its ...
Use _myVariable instead of myvariable to remove this warning. ... First, turn off noUnusedLocals in tsconfig.json:
Read more >
Documentation - tsc CLI Options - TypeScript
Flag Type Default ‑‑allowJs boolean false ‑‑allowUmdGlobalAccess boolean false ‑‑allowUnreachableCode boolean
Read more >
How to get the most out of Angular configuration - Medium
noUnusedLocals. This flag allows a TypeScript to report an error if a declared variable is not used: // Error: 'OnInit' is declared but...
Read more >
CodeBuild provisioning template bundle - AWS Proton
With CodeBuild provisioning, instead of using IaC templates to render IaC files and run them using an IaC provisioning engine, AWS Proton simply...
Read more >
CodeMix problems view - Genuitec
In ts editor, there are also sometimes stale warnings like The 'use-output-property-decorator' rule threw an error in 'xx/app.module.ts': ...
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