-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.2.1
Code
I'm having some problems with using the new syntax for mixins. Consider the following example:
export abstract class Item {
foo(): void {}
}
export class FooItem extends Item {
name?: string;
toString(): string {
if (this.name) {
return this.name;
}
return `${this.id}`;
}
}
export type Constructor<T> = new(...args: any[]) => T;
// Throws an error when compiled
// "Error TS4060: Return type of exported function has or is using private name '(Anonymous class)'.
export function WithTags<T extends Constructor<FooItem>>(Base: T) {
return class extends Base {
static getTags(): Promise<any> { ... }
tags(): Promise<any> { ... }
}
}
// Throws two errors:
// At `Test`: "Error TS4093: 'extends' clause of exported class 'Test' refers to a type whose name cannot be referenced."
// At `WithTags`: "Error TS4020: 'extends' clause of exported class 'Test' has or is using private name '(Anonymous class)'."
export class Test extends WithTags(FooItem) {}
const test = new Test();
Test.getTags()
test.tags();Expected behavior:
It should not throw any errors.
Actual behavior:
It throws those three errors that are described in the code comments.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue