TypeScript Version: 4.1.0-beta
Search Terms: accessor property subclass mapped types
Code
typeTypes='boolean'|'unknown'|'string';typeProperties<Textends{[key: string]: Types}>={readonly[keyinkeyofT]: T[key]extends'boolean' ? boolean : T[key]extends'string' ? string : unknown}typeAnyCtor<Pextendsobject>=new(...a: any[])=>PdeclarefunctionclassWithProperties<Textends{[key: string]: Types},Pextendsobject>(properties: T,klass: AnyCtor<P>): {new(): P&Properties<T>;prototype: P&Properties<T>};constBase=classWithProperties({x: 'boolean',y: 'string',z: 'unknown'},classBase{});classMyClassextendsBase{constructor(){super();}// Errors with: 'x' is defined as a property in class 'Base & Properties<{ x: "boolean"; y: "string"; z: "unknown"; }>', but is // overridden here in 'MyClass' as an accessor. (2611)getx(){returnfalse;}}constmine=newMyClass();constvalue=mine.x;Expected behavior:
I can create subclasses of mapped types when the mapped type defines a property and the subclass defines an accessor.
Actual behavior:
TypeScript gives an error saying you can't override a property with an accessor.
Playground Link:Link
Related Issues: I know this is related to the change in behavior in 4.0 to universally disallow accessors overriding properties.
TypeScript Version: 4.1.0-beta
Search Terms: accessor property subclass mapped types
Code
Expected behavior:
I can create subclasses of mapped types when the mapped type defines a property and the subclass defines an accessor.
Actual behavior:
TypeScript gives an error saying you can't override a property with an accessor.
Playground Link:Link
Related Issues: I know this is related to the change in behavior in 4.0 to universally disallow accessors overriding properties.