-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Unexpectedly report error on correct code: 'field' is declared but its value is never read.(6133)'. #35153
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
Are you sure this comes from the compiler? This looks more like a linter error to me. |
@ajafff It does come form the compiler if |
@dragomirtitian the OP mentions The error you get with |
One of these errors comes from tslint |
I don't think so, since https://www.typescriptlang.org/play/ gives me this error too. Unless it has tslint turned on. |
@vczh Look at the error message. It's different in the TypeScript playground |
@ajafff playground shows |
TypeScript Version: 3.7.2
Search Terms: Put the error message but I don't recognize any similar issue by reading titles.
Code
Expected behavior: No error is reported
Actual behavior: 'field' is declared but its value is never read.(6133).
Private member
field
could be assigned by assigning tothis[name]
whilename
has the type'field'
(or any string literal union that contains'field'
). So I believe this error message is incorrect.If I add
readonly
to this field,this[name] = value;
will report another error: Cannot assign to 'field' because it is a read-only property.The compiler leaves me no space for writing code like this.
Playground Link: N/A
Related Issues: N/A
The text was updated successfully, but these errors were encountered: