Skip to content

Refactored code that uses ASI is borked #37813

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
DanielRosenwasser opened this issue Apr 6, 2020 · 0 comments · Fixed by #37846
Closed

Refactored code that uses ASI is borked #37813

DanielRosenwasser opened this issue Apr 6, 2020 · 0 comments · Fixed by #37846
Assignees
Labels
Bug A bug in TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol Fix Available A PR has been opened for this issue

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Apr 6, 2020

Found from #37814.

function foo() {
    [|var x: number

    x = 10;
    return x;|]
}

Extract [| this range |] to a function in the global scope.

Expected:

function foo() {
    return yadda();
}

function yadda() {
    var x: number;
    
    x = 10;
    return x;
}

or

function foo() {
    return yadda();
}

function yadda() {
    var x: number
    
    x = 10;
    return x;
}

Actual:

function foo() {
    return yadda();
}

function yadda() {
    var x: number

        ;

    x = 10;
    return x;
}
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Apr 6, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.9.1 milestone Apr 6, 2020
@DanielRosenwasser DanielRosenwasser added the Domain: Refactorings e.g. extract to constant or function, rename symbol label Apr 8, 2020
@andrewbranch andrewbranch added the Fix Available A PR has been opened for this issue label Apr 8, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug A bug in TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol Fix Available A PR has been opened for this issue
Projects
None yet
3 participants