Files
tsgo/testdata/baselines/reference/compiler/declarationEmitForMixinsWithStaticAccessors1.js
88d31a45dd Fix nil pointer dereference in addPropertyToElementList (#3361)
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: DanielRosenwasser <[email protected]>
2026-04-15 04:09:38 +00:00

78 lines
2.0 KiB
TypeScript

//// [tests/cases/compiler/declarationEmitForMixinsWithStaticAccessors1.ts] ////
//// [declarationEmitForMixinsWithStaticAccessors1.ts]
// Regression test: when a class extends a mixin that returns an intersection,
// the class's anonymous constructor type inherits static accessor properties from the
// intersection. These synthetic properties can have a nil parent symbol when the
// constituent accessor declarations differ. Declaration emit must not crash when
// serializing these properties.
function mix<T extends new (...args: any[]) => any, U extends new (...args: any[]) => any>(
base1: T, base2: U
): T & U {
return null as any;
}
class A {
static get shared(): number { return 1; }
static set shared(v: number) { }
x: string = "";
}
class B {
static get shared(): number { return 2; }
static set shared(v: number) { }
y: number = 0;
}
function make() {
class C extends mix(A, B) {
z: boolean = true;
}
return C;
}
export const MixedClass = make();
//// [declarationEmitForMixinsWithStaticAccessors1.js]
// Regression test: when a class extends a mixin that returns an intersection,
// the class's anonymous constructor type inherits static accessor properties from the
// intersection. These synthetic properties can have a nil parent symbol when the
// constituent accessor declarations differ. Declaration emit must not crash when
// serializing these properties.
function mix(base1, base2) {
return null;
}
class A {
static get shared() { return 1; }
static set shared(v) { }
x = "";
}
class B {
static get shared() { return 2; }
static set shared(v) { }
y = 0;
}
function make() {
class C extends mix(A, B) {
z = true;
}
return C;
}
export const MixedClass = make();
//// [declarationEmitForMixinsWithStaticAccessors1.d.ts]
export declare const MixedClass: {
new (): {
z: boolean;
x: string;
};
new (): {
z: boolean;
x: string;
};
shared: number;
};