-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
fix(ts): raise TSError for class accessors with discarding accessibility
#13250
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
Conversation
| public get bar() {} | ||
| set bar(v) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a TS bug 🤔
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/47131/ |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d97eda5:
|
|
|
||
| enter() { | ||
| this.stack.push(new ClassScope()); | ||
| this.stack.push(this.createScope()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot call 'this.stack.push' because 'ClassScope' [1] is incompatible with 'IClassScope' [2] in array element.
Why this? Shouldn't it be allowed since IClassScope: ClassScope?
JLHwung
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the behaviour of different accessibility for accessors has changed in TS 4.3:
class Foo {
public get f() { return 1 }
private set f(x) {}
}Based on that we may want to hold off this PR and close #13125 since it does not throw on TS 4.3
class Foo {
protected get foo() { return 1 }
set foo(v: any) { }
}In 4.3.0 accessors are allowed to have a different accessibility level, but getters must have at least the same level of the setters. https://www.typescriptlang.org/play?ts=4.3.0-beta#code/MYGwhgzhAEBiD29oG8BQ0PQA4Cd4BcBTYIgE2gHND9oAzRACgEoVodqBXHAO2gEZoAX3SYI1OowBuALmhhuATxbIhqQUA |
706c907 to
d97eda5
Compare
|
Closing this, we may want to check the correct behaviour when implementing auto accessors |
We override
ClassScopeHandlerin the TS plugin so that it is possible to check for class accessors with different accessibility levels.In this PR we do not take into account
MemberExpressionandCallExpressionkeys because TS does not return any error for those