Bug Report
π Search Terms
auto accessor readonly declare
π Version & Regression Information
Version 4.9.3
- I was unable to test this on prior versions because the auto-accessor feature is new in 4.9
β― Playground Link
Playground link with relevant code
π» Code
class Foo {
accessor readonly foo: number = 5;
// ^ no error here
accessor declare bar: string;
// ^ no error here
}
const myc = new Foo();
myc.foo = 6;
// property is not read-only, which is correct because trying to
// define it read-only as above should be an error in the first place
π Actual behavior
No TypeScript error is shown, neither for readonly nor for declare.
readonly is completely ignored, i.e. writing to the property also does not result in an error.
π Expected behavior
In the auto-accessor PR description, it is explicitly stated that
accessor cannot be used with readonly or declare on the same field declaration.
So I'd expect a corresponding TypeScript error message for both accessor declarations in the example above.
Once using readonly on an accessor raises an error, it is correct to ignore this for further analysis, so the current behavior to not report an error when trying to write to the property is correct and should remain as-is.
Bug Report
π Search Terms
auto accessor readonly declare
π Version & Regression Information
Version 4.9.3
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
No TypeScript error is shown, neither for
readonlynor fordeclare.readonlyis completely ignored, i.e. writing to the property also does not result in an error.π Expected behavior
In the auto-accessor PR description, it is explicitly stated that
So I'd expect a corresponding TypeScript error message for both accessor declarations in the example above.
Once using
readonlyon an accessor raises an error, it is correct to ignore this for further analysis, so the current behavior to not report an error when trying to write to the property is correct and should remain as-is.