Skip to content

2.1 Regression: Definite assignment with try..finally #12355

Description

@jods4

TypeScript Version: 2.1.? / the one that comes with VS 2017 RC

Code

async function bug() {
    let response: Response;
    try {
        response = await fetch("www.google.com");
    }    
    finally {
    }
    if (response.ok)  // <- error: Variable response is used before being assigned
        console.log("ok");
}

Expected behavior: was compiling (and working) fine in TS 2.0

Actual behavior: Error: response is used before being assigned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions