We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
TypeScript Version: 3.9.0-dev.20200220
Search Terms:
Code
class Regular { protected foo = 1; } function regular(this: Regular) { this.foo; // works } class Generic<T> { protected foo = 1; } function generic(this: Generic<unknown>) { this.foo; // error }
Expected behavior:
There should be no difference between generic and non-generic classes. Both functions should be allowed to access this.foo.
this.foo
Actual behavior:
Property 'foo' is protected and only accessible through an instance of class 'Generic<unknown>'.(2446)
Playground Link: http://www.typescriptlang.org/play/?ts=3.9.0-dev.20200220#code/MYGwhgzhAEBKCmBzAruATtA3gKGn6ADmgPYAu8w5AJtAGbHHQC80AjANzYC+22tyAO0oBLYgOhokqMGgAUpABbCIALjhT0ASiy58i5QDp6xdtAD0Z6AHdiaANYRuvUJBgBxeAPhphwADwAKgB8OviEJOSU8DTGzGycPHyCImLQiJ7evvJKqtAeXj7+gnYCxFYCQdo4YfoQRgymFtDeJGjcQA
Related Issues:
The text was updated successfully, but these errors were encountered:
Fix access of protected members on generic this-type
7eb6403
Fixes: microsoft#36926
Fix access of protected members on generic this-type (#36928)
24dd93f
Fixes: #36926
Successfully merging a pull request may close this issue.
TypeScript Version: 3.9.0-dev.20200220
Search Terms:
Code
Expected behavior:
There should be no difference between generic and non-generic classes. Both functions should be allowed to access
this.foo
.Actual behavior:
Playground Link: http://www.typescriptlang.org/play/?ts=3.9.0-dev.20200220#code/MYGwhgzhAEBKCmBzAruATtA3gKGn6ADmgPYAu8w5AJtAGbHHQC80AjANzYC+22tyAO0oBLYgOhokqMGgAUpABbCIALjhT0ASiy58i5QDp6xdtAD0Z6AHdiaANYRuvUJBgBxeAPhphwADwAKgB8OviEJOSU8DTGzGycPHyCImLQiJ7evvJKqtAeXj7+gnYCxFYCQdo4YfoQRgymFtDeJGjcQA
Related Issues:
The text was updated successfully, but these errors were encountered: