Files
test-repo/tests/class_statics/test.js
T
Christopher Chedeau cf45afba61 Add testing
- This brings in the flow test suite that contains a ton of JavaScript parsing edge cases
- This creates snapshot tests using the pretty printer for all of them
- If uncomment `RUN_AST_TESTS` line in `tests/run_specs.js`, it checks ast(pretty_print(x)) == ast(x). Right now, "178 failed, 197 passed, 375 of 377 total". So half of the tests are not passing, most of them are crashes and many of the rest are subtle issues.
2016-12-23 19:51:53 +00:00

62 lines
1.0 KiB
JavaScript

class A {
static x: number;
static y: string;
static foo(x: number) { }
static bar(y: string) { }
}
A.qux = function(x: string) { } // error?
class B extends A {
static x: string; // error?
static foo(x: string) { } // error?
static main() {
B.x = 0; // error
B.x = "";
B.foo(0); // error
B.foo("");
B.y = 0; // error
B.bar(0); // error
B.qux(0); // error
}
static create(): A {
return new this();
}
static badCreate(): number {
return new this(); // error B ~> number
}
}
class C<X> {
static x: X;
static bar(x: X) { }
static create(): C<*> {
return new this();
}
}
class D extends C<string> {
static main() {
D.foo(0); // error?
D.bar(0);
}
}
var d: C<*> = D.create();
(new A: typeof A);
(B: typeof A);
class E {
static x: number;
static foo(): string {
this.bar(); // error
return this.x; // error
}
}
// note: above classdefs are sufficiently annotated to export
module.exports = {
A: A, B: B, C: C, D: D, E: E
}