Closed
Description
Using union types in base class method declarations allows override functions that only declare one of the union member types. This produces code that crashes at runtime, even with --strict.
TypeScript Version: 2.7.0-dev.20171108
Code
abstract class Base {
abstract foo(arg: string | number): boolean
}
class C extends Base {
foo(arg: string): boolean {
return arg.startsWith("a")
};
}
const a: Base = new C()
a.foo(1)
Expected behavior:
Should not compile.
Actual behavior:
Compiles and crashes at runtime.