Skip to content

Weird 'referenced directly or indirectly in its own initializer' error #14428

Closed
@vilicvane

Description

@vilicvane

TypeScript Version: 2.2.1

Code

(async () => {
    function foo(p: string[]): string[] {
        return [];
    }

    function bar(p: string[]): string[] {
        return [];
    }

    let a1: string[] | undefined = [];

    while (true) {
        let a2 = foo(a1!);
        a1 = await bar(a2);
    }
});

With noImplicitAny and strictNullChecks turned on, this gives error:

'a2' 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

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions