Skip to content

Type assertion with as operator does not work on recursive functions #5403

@saschanaz

Description

@saschanaz

With --noImplicitAny:

function foo() {
    let element = foo() as number;
    return element;
}
/*
issue5403.ts(1,10): error TS7023: '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.
issue5403.ts(2,6): error TS7022: 'element' implicitly has type 'any' because it does not have
a type annotation and is referenced directly or indirectly in its own initializer.
*/

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