Skip to content

Return type annotation missing error #1146

@NoelAbrahams

Description

@NoelAbrahams

Hi,

VS: 2013 Update 4
TS: 1.3

Here's some code that compiles correctly:

class Base {

    foo() {
        return this;
    }
}

class Derived extends Base {

    foo() {
        return super.foo();
    }
}

Here's some other code that fails:

class Base2 {

    foo() {
        return this;
    }
}

class Derived2 extends Base2 {

    // 'foo' implicitly has return type 'any' because it does not have a 
    // return type annotation and is referenced directly or indirectly in 
    // one of its return expressions.
    foo() {
        return <Derived2> super.foo();
    }
}

I'm aware that a bug with implicit-any and recursive methods has been fixed, but to me it's pretty clear that the return value for Derived2.foo is Derived2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions