[bug] Auto accessor
fields are declared as regular properties in mixin abstract classes #60672
Open
Description
🔎 Search Terms
abstract class mixin accessor field property declaration .d.ts ts(2611)
🕗 Version & Regression Information
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
💻 Code
// `index.d.ts` is generated by `tsc --emitDeclarationOnly` in `my-library`
declare abstract class Base {
accessor a: number;
}
declare function middle(Super?: typeof Base): abstract new () => {
a: number;
};
// import { middle } from 'my-library';
class Final extends middle() {
accessor a = 2; // ts(2611) error
}
🙁 Actual behavior
TS throws:
'a' is defined as a property in class '{ a: number; }', but is overridden here in 'Final' as an accessor. ts(2611)
but the library source code is:
export abstract class Base {
accessor a = 1;
}
export function middle(Super = Base) {
abstract class Middle extends Super {
}
return Middle;
}
🙂 Expected behavior
It has no type error while overrides auto accessor
fields in sub classes of abstract mixins from 3rd-party libraries.
Additional information about the issue
This bug can be resolved if tsc
generates .d.ts
as shown below:
// `index.d.ts` is generated by `tsc --emitDeclarationOnly` in `my-library`
declare abstract class Base {
accessor a: number;
}
declare function middle(Super?: typeof Base): abstract new () => {
- a: number;
+ get a(): number;
+ set a(value: number);
};
// import { middle } from 'my-library';
class Final extends middle() {
accessor a = 2; // no error
}