TypeScript/tests/cases/compiler/declarationNoDanglingGenerics.ts
Wesley Wigham aea7e9a7a8 Fix instantiated generic mixin declaration emit (#19144)
* Fix #18545, dont use declared type of class expression

* Accept API Baselines

* Add thus far unused flag from node builder

* Accept baseline update
2017-10-16 14:17:55 -07:00

33 lines
723 B
TypeScript

// @declaration: true
const kindCache: { [kind: string]: boolean } = {};
function register(kind: string): void | never {
if (kindCache[kind]) {
throw new Error(`Class with kind "${kind}" is already registered.`);
}
kindCache[kind] = true;
}
function ClassFactory<TKind extends string>(kind: TKind) {
register(kind);
return class {
static readonly THE_KIND: TKind = kind;
readonly kind: TKind = kind;
};
}
class Kinds {
static readonly A = "A";
static readonly B = "B";
static readonly C = "C";
}
export class AKind extends ClassFactory(Kinds.A) {
}
export class BKind extends ClassFactory(Kinds.B) {
}
export class CKind extends ClassFactory(Kinds.C) {
}