mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
18 lines
630 B
Plaintext
18 lines
630 B
Plaintext
accessorsOverrideProperty2.ts(6,7): error TS2611: 'x' is defined as a property in class 'Base', but is overridden here in 'Derived' as an accessor.
|
|
|
|
|
|
==== accessorsOverrideProperty2.ts (1 errors) ====
|
|
class Base {
|
|
x = 1;
|
|
}
|
|
|
|
class Derived extends Base {
|
|
get x() { return 2; } // should be an error
|
|
~
|
|
!!! error TS2611: 'x' is defined as a property in class 'Base', but is overridden here in 'Derived' as an accessor.
|
|
set x(value) { console.log(`x was set to ${value}`); }
|
|
}
|
|
|
|
const obj = new Derived(); // nothing printed
|
|
console.log(obj.x); // number
|
|
|