swc/crates/swc_ecma_parser/tests/tsc/derivedClassTransitivity2.ts

20 lines
391 B
TypeScript

// subclassing is not transitive when you can remove required parameters and add optional parameters
class C {
foo(x: number, y: number) { }
}
class D extends C {
foo(x: number) { } // ok to drop parameters
}
class E extends D {
foo(x: number, y?: string) { } // ok to add optional parameters
}
var c: C;
var d: D;
var e: E;
c = e;
var r = c.foo(1, 1);
var r2 = e.foo(1, '');