-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 2.0.3
Code
// This works as expected
class Demo1 {
get foo() {
return 'hi';
}
}
let d1 = new Demo1();
d1.foo = 'wat'; // An error is given (as it should be) because foo is read-only.
// This does NOT work as expected
class Demo2 {
private _foo: string;
set foo(foo: string) {
this._foo = foo;
}
}
let d2 = new Demo2();
console.log(d2.foo); // No error, but there should be because foo is write-only.
Expected behavior:
A compiler error should be given when attempting to read a write-only property.
Actual behavior:
There is no compiler error.
dead-claudia, dungdm93, begincalendar, raspyweather and tfaller
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created