mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
90 lines
2.1 KiB
TypeScript
90 lines
2.1 KiB
TypeScript
//// [tests/cases/compiler/declarationEmitLocalClassDeclarationMixin.ts] ////
|
|
|
|
//// [declarationEmitLocalClassDeclarationMixin.ts]
|
|
interface Constructor<C> { new (...args: any[]): C; }
|
|
|
|
function mixin<B extends Constructor<{}>>(Base: B) {
|
|
class PrivateMixed extends Base {
|
|
bar = 2;
|
|
}
|
|
return PrivateMixed;
|
|
}
|
|
|
|
export class Unmixed {
|
|
foo = 1;
|
|
}
|
|
|
|
export const Mixed = mixin(Unmixed);
|
|
|
|
function Filter<C extends Constructor<{}>>(ctor: C) {
|
|
abstract class FilterMixin extends ctor {
|
|
abstract match(path: string): boolean;
|
|
// other concrete methods, fields, constructor
|
|
thing = 12;
|
|
}
|
|
return FilterMixin;
|
|
}
|
|
|
|
export class FilteredThing extends Filter(Unmixed) {
|
|
match(path: string) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
//// [declarationEmitLocalClassDeclarationMixin.js]
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.FilteredThing = exports.Mixed = exports.Unmixed = void 0;
|
|
function mixin(Base) {
|
|
class PrivateMixed extends Base {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.bar = 2;
|
|
}
|
|
}
|
|
return PrivateMixed;
|
|
}
|
|
class Unmixed {
|
|
constructor() {
|
|
this.foo = 1;
|
|
}
|
|
}
|
|
exports.Unmixed = Unmixed;
|
|
exports.Mixed = mixin(Unmixed);
|
|
function Filter(ctor) {
|
|
class FilterMixin extends ctor {
|
|
constructor() {
|
|
super(...arguments);
|
|
// other concrete methods, fields, constructor
|
|
this.thing = 12;
|
|
}
|
|
}
|
|
return FilterMixin;
|
|
}
|
|
class FilteredThing extends Filter(Unmixed) {
|
|
match(path) {
|
|
return false;
|
|
}
|
|
}
|
|
exports.FilteredThing = FilteredThing;
|
|
|
|
|
|
//// [declarationEmitLocalClassDeclarationMixin.d.ts]
|
|
export declare class Unmixed {
|
|
foo: number;
|
|
}
|
|
export declare const Mixed: {
|
|
new (...args: any[]): {
|
|
bar: number;
|
|
};
|
|
} & typeof Unmixed;
|
|
declare const FilteredThing_base: (abstract new (...args: any[]) => {
|
|
match(path: string): boolean;
|
|
thing: number;
|
|
}) & typeof Unmixed;
|
|
export declare class FilteredThing extends FilteredThing_base {
|
|
match(path: string): boolean;
|
|
}
|
|
export {};
|