-
Notifications
You must be signed in to change notification settings - Fork 12.9k
False positive Error - TS6133 error (declared but its value is never read) report. #19700
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
Comments
Since you never use the value of this property anywhere, I'd say the error is expected. |
@mhegazy: Thanks for the doc. |
Using private vars in .vue files in template reported as unused. Changing to protected solved the issue. |
It causes a lot of problems in Angular
And OnInit is reported as "is declared but its value is never read." |
@mentatxx can you provide a self-contained repro? I can't reproduce the problem |
Having same issue here, have a variable that is declared, populated on ngOnInit and is used on the template.. but TS can't see this using in the template.. in my case i have it changed in tsconfig.conf like |
The same issue with angulal specs - declaring a spy leads to the same error. |
Hi there, |
Duplicate of #21478, should be fixed in |
Getting false positives with Jest tests ("typescript": "^2.7.2") import {
fetchDevices
} from "./api";
describe("fetchDevices", () => {
describe("positive scenario", () => {
it("fetches devices data", () => {
fetchDevices("").then(data => |
Still getting the same error with typescript 2.7.2, any solution ? |
#metoo , here's one of the many errors I get, administration.component.ts[21, 11]: 'title' is declared but its value is never read.
|
Set this in your ts.config, I absolutely hate the compiler telling me about unused variables during dev time, sure, for prod build it makes sense but during development it is one of the most annoying things and the main reason I avoid golang "compilerOptions": {
...
"noUnusedLocals": false
}, |
Then work normally with varname1. |
Getting the same error with TS 3:
|
@vp93 your "workaround" introduces new errors in the class, there isn't a TS bug here, and declaring a property doesn't really mark it as used. @jadbox |
There must be a way to set severity of unused locals to "warning", instead of fatal error that prevents the script from being compiled. Or ideally, it should be a part of linter (tslint) rather then compiler. Here is a real world example of how annoying it is right now. When I'm writing unit tests, I usually comment some parts of code that should not be triggered while I'm writing tests, because it will do some DB requests that I don't want to be triggered. I may comment half of a file and then it starts yelling at me about unused imports and it won't compile my tests until I comment all of the imports as well |
@ilearnio the default behavior of the compiler is to emit files even in the presence of errors. Effectively, all errors are warnings. You can also use You can also just turn off |
@RyanCavanaugh Yeah, it seems that my issue is more related to Mocha that I'm using for testing, because for regular compilation with |
Another case with private parameters listed in constructor
The code is working just right and renderer is got from propGenerator but: ERROR in src/app/some.service.ts(11,23): error TS6138: Property 'renderer' is declared but its value is never read. Repo https://github.com/DzmVasileusky/angular-ts-lint-issue-1 |
it work for me, big sister, thx O(∩_∩)O |
This can be disabled by setting |
prefix the variable with an underscore :) in @DzmVasileusky's example
|
import React from 'react'; class Demo extends Component{ Wellcome hamxa
} Declaration or statement expected.ts(1128) |
Holy Moly!! This was a genius suggestion. Worked like a charm. Thanks |
Uh oh!
There was an error while loading. Please reload this page.
tsc --version
Version 2.6.1 , Also tried on 2.7.0-dev.20171102
and then compile file: tsc --noUnusedLocals
Expected behavior: No erros
Actual behavior: error TS6133: 'manualPriceTotal' is declared but its value is never read.
The text was updated successfully, but these errors were encountered: