Skip to content

Convert to ES6 Class Refactoring fails with empty case statement #18437

New issue

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

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

Already on GitHub? Sign in to your account

Closed
hbenl opened this issue Sep 13, 2017 · 0 comments
Closed

Convert to ES6 Class Refactoring fails with empty case statement #18437

hbenl opened this issue Sep 13, 2017 · 0 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@hbenl
Copy link

hbenl commented Sep 13, 2017

TypeScript Version: nightly (2.6.0-dev.20170913)

Try the refactoring on the following code:
Code

function MyClass() {
}
MyClass.prototype.foo = function(x) {
    switch(x) {
        case 0:
    }
}

Expected behavior:
The refactoring is applied

Actual behavior:
The code is unchanged, an error is thrown:

[Error  - 13:34:21] 'getEditsForRefactor' request failed with error.
Error processing request. Debug Failure. False expression.
Error: Debug Failure. False expression.
    at getPos (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:72799:22)
    at assignPositionsToNodeArray (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73238:29)
    at Object.visitEachChild (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:43037:104)
    at assignPositionsToNode (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73226:30)
    at Object.visitNodes (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42752:48)
    at assignPositionsToNodeArray (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73233:30)
    at Object.visitEachChild (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42995:49)
    at assignPositionsToNode (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73226:30)
    at visitNode (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42715:23)
    at Object.visitEachChild (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42969:100)
    at assignPositionsToNode (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73226:30)
    at Object.visitNodes (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42752:48)
    at assignPositionsToNodeArray (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73233:30)
    at Object.visitEachChild (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42943:45)
    at assignPositionsToNode (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73226:30)
    at visitNode (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42715:23)
    at visitFunctionBody (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42798:23)
    at Object.visitEachChild (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42837:510)
    at assignPositionsToNode (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73226:30)
    at Object.visitNodes (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42752:48)
    at assignPositionsToNodeArray (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73233:30)
    at Object.visitEachChild (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:42983:355)
    at assignPositionsToNode (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73226:30)
    at getNonformattedText (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73202:52)
    at ChangeTracker.getFormattedTextOfNode (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73169:40)
    at ChangeTracker.computeNewText (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73163:33)
    at c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73138:44
    at Map.forEach (native)
    at ChangeTracker.getChanges (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73131:32)
    at Object.getEditsForAction (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:74917:42)
    at Object.getEditsForRefactor (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:73396:41)
    at Object.getEditsForRefactor (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:77392:32)
    at IOSession.Session.getEditsForRefactor (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:83294:59)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:82256:61)
    at c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:83470:88
    at IOSession.Session.executeWithRequestId (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:83461:28)
    at IOSession.Session.executeCommand (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:83470:33)
    at IOSession.Session.onMessage (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:83490:35)
    at Interface.<anonymous> (c:\GitTF\Aktuell\WebDispo\node_modules\typescript\lib\tsserver.js:84621:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

Note that it works in 2.5.2.
It also works in nightly if you add any statement after case 0:.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Sep 13, 2017
@mhegazy mhegazy added this to the TypeScript 2.6 milestone Sep 14, 2017
@mhegazy mhegazy assigned ghost and unassigned amcasey Sep 14, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Sep 14, 2017
@ghost ghost closed this as completed in #18484 Sep 14, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants