-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Accessing protected computed property does not produce a compiler error #60974
Comments
This is working as intended, duplicate #19335 |
(I'd respond in the original issue, but it is limited to collaborators only) I think, there needs to be a distinction between intended usage of bracket notation where dot notation is available, and unavoidable usage of bracket notation where dot notation is not available. I.e., my original use case is using a symbol as property key, β I can't not use bracket notation: const key = Symbol('key')
declare class Foo {
protected readonly [key]: number
}
declare class Bar {
readonly foo: Foo
}
declare const bar: Bar
console.log(bar.foo[key].toFixed(2)) // no errors π AFAICT, TypeScript parser already has a mechanism to differentiate literals (such as |
Should I open a feature request? |
How could you even distinguish the two cases? |
You could possibly file a feature request, but similar things like #50485 have been declined. Not sure if someone has brought up symbol keys before, but I imagine you'll get the same response. |
π Search Terms
protected computed no error bug
π Version & Regression Information
This is the behavior in every version I tried (v3.3.3333, v4.0.5, v5.7.3), and I reviewed the FAQ for entries about Common "Bugs" That Aren't Bugs
β― Playground Link
https://tsplay.dev/wjdn7m
π» Code
π Actual behavior
// @ts-expect-error
): No errors// @ts-expect-error
): Compiler errorUnused '@ts-expect-error' directive
π Expected behavior
// @ts-expect-error
): Compiler errorProperty [β¦] is protected and only accessible within class 'Foo' and its subclasses
// @ts-expect-error
): No errorsAdditional information about the issue
No response
The text was updated successfully, but these errors were encountered: