Microsoft/TypeScript
GitHub ã§èŠãMixed-in classes with functions returning 'this' have TS2526 error in DTS file
Open
#52,687 opened on 2023幎2æ8æ¥
BugDomain: Declaration EmitHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
Bug Report
ð Search Terms
TS2526 mixin declaration this
ð Version & Regression Information
- This is the behavior in every version I tried
⯠Playground Link
ð» Code
class Sprite {
name = "";
constructor(name: string) {
this.name = name;
}
}
type Constructor = new (...args: any[]) => {};
function Scale<TBase extends Constructor>(Base: TBase) {
return class Scaling extends Base {
_scale = 1;
setScale(scale: number): this {
this._scale = scale;
return this;
}
};
}
export const A = Scale(Sprite);
DTS:
declare class Sprite {
name: string;
constructor(name: string);
}
export declare const A: {
new (...args: any[]): {
_scale: number;
// A 'this' type is available only in a non-static member of a class or interface.ts(2526)
setScale(scale: number): this;
};
} & typeof Sprite;
export {};
ð Actual behavior
TS2526 error appears in emitted dts file
ð Expected behavior
No error (TS files that have no errors should not emit DTS file with errors)