Skip to content

override a method with lesser arguments don't generate a error #26533

@pjannesen

Description

@pjannesen

TypeScript Version: 3.0.1 with --strict

class A {
    public m(a:string|null): string {
        return "";
    }
}

class B extends A {
    public m(a:string): string {
        return "";
    }
}

Expected behavior:
Error message

Actual behavior:
No error

B.m override the method A.m so the following code is valid.

let a:A = new B()
a.m(null);

But now B.m is called with null this violates the typing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions