-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this
Milestone
Description
TypeScript Version: 2.9.2
Search Terms:
--noUnusedLocals
+=
private property
Code
tsconfig.json:
{
"compileOnSave": true,
"compilerOptions": {
"target": "es6",
"module": "none",
"noImplicitAny": true,
"removeComments": false,
"outFile": "test.js",
"declaration": false,
"noEmitOnError": true,
"sourceMap": false,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true
}
}
test.ts
export class TestClass {
private mNumber: number = 0;
private get Number(): number { return this.mNumber; }
private set Number(value: number) { this.mNumber = value; }
public DoSomething() {
this.Number += 1;
}
}
Result
c:\Temp>tsc
test.ts(3,16): error TS6133: 'Number' is declared but its value is never read.
Expected behavior:
+= should count as both a read and a write
Actual behavior:
+= seems to count as a write but not a read. though this problem doesn't occur with a public property.
Playground Link:
I don't think I can set --noUnusedLocals on the playground
Related Issues:
I found this "noUnusedLocals checks don't work with private modifier": #15775
but it was closed
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this