-
Notifications
You must be signed in to change notification settings - Fork 12.8k
/
Copy pathdeclarationEmitLocalClassDeclarationMixin.js
114 lines (104 loc) · 3.49 KB
/
declarationEmitLocalClassDeclarationMixin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//// [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";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FilteredThing = exports.Mixed = exports.Unmixed = void 0;
function mixin(Base) {
var PrivateMixed = /** @class */ (function (_super) {
__extends(PrivateMixed, _super);
function PrivateMixed() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.bar = 2;
return _this;
}
return PrivateMixed;
}(Base));
return PrivateMixed;
}
var Unmixed = /** @class */ (function () {
function Unmixed() {
this.foo = 1;
}
return Unmixed;
}());
exports.Unmixed = Unmixed;
exports.Mixed = mixin(Unmixed);
function Filter(ctor) {
var FilterMixin = /** @class */ (function (_super) {
__extends(FilterMixin, _super);
function FilterMixin() {
var _this = _super !== null && _super.apply(this, arguments) || this;
// other concrete methods, fields, constructor
_this.thing = 12;
return _this;
}
return FilterMixin;
}(ctor));
return FilterMixin;
}
var FilteredThing = /** @class */ (function (_super) {
__extends(FilteredThing, _super);
function FilteredThing() {
return _super !== null && _super.apply(this, arguments) || this;
}
FilteredThing.prototype.match = function (path) {
return false;
};
return FilteredThing;
}(Filter(Unmixed)));
exports.FilteredThing = FilteredThing;
//// [declarationEmitLocalClassDeclarationMixin.d.ts]
export declare class Unmixed {
foo: number;
}
export declare const Mixed: {
new (...args: any[]): {
bar: number;
};
} & typeof Unmixed;
export declare class FilteredThing extends ({} as (abstract new (...args: any[]) => {
match(path: string): boolean;
thing: number;
}) & typeof Unmixed) {
match(path: string): boolean;
}