-
Notifications
You must be signed in to change notification settings - Fork 12.8k
in type signatures, cannot refer to class defined as static anonymous class #7421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems like something we could do. In the meantime, you can rewrite this to something that is basically equivalent: export abstract class CaseClass {
constructor(...args: any[]) { }
}
abstract class TestCaseClass extends CaseClass {
}
namespace TestCaseClass {
export class A extends TestCaseClass {
v: number;
constructor(v: number) {
super();
this.v = v;
}
}
export class B extends TestCaseClass {
v: string;
constructor(v: string) {
super();
this.v = v;
}
};
}
function test(v: TestCaseClass.A) {
return v.v;
} |
You could also write something like this: export abstract class CaseClass {
constructor(...args: any[]) {}
}
abstract class TestCaseClass extends CaseClass {
static A = class extends TestCaseClass {
v: number;
constructor(v: number) {
super();
this.v = v;
}
};
static B = class extends TestCaseClass {
v: string;
constructor(v: string) {
super();
this.v = v;
}
};
}
function test(v: typeof TestCaseClass.A.prototype) {
return v.v
} |
We might potentially turn class names into namespaces if this turns out to be a common pattern, but for now it doesn't look like there's much demand for it |
Haven't gotten any other feedback on this. For non-abstract classes you can write |
TypeScript Version:
nightly (1.9.0-dev.20160307)
Code
Expected behavior:
I would expect this to compile.
Actual behavior:
A failure in the compilation of
test
:error TS2503: Cannot find namespace \'TestCaseClass\'.
The text was updated successfully, but these errors were encountered: