TypeScript Version: 3.0.0-dev.20180712
Search Terms:
Code
Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isLabeledStatement'.
at Object.cast (/usr/local/lib/node_modules/typescript/lib/tsserver.js:1291:22)
at doChange (/usr/local/lib/node_modules/typescript/lib/tsserver.js:106152:39)
at /usr/local/lib/node_modules/typescript/lib/tsserver.js:106144:96
at Function.ChangeTracker.with (/usr/local/lib/node_modules/typescript/lib/tsserver.js:102880:17)
at Object.getCodeActions (/usr/local/lib/node_modules/typescript/lib/tsserver.js:106144:64)
at /usr/local/lib/node_modules/typescript/lib/tsserver.js:103819:121
at Object.flatMap (/usr/local/lib/node_modules/typescript/lib/tsserver.js:498:25)
at Object.getFixes (/usr/local/lib/node_modules/typescript/lib/tsserver.js:103819:23)
at /usr/local/lib/node_modules/typescript/lib/tsserver.js:111665:35
at Object.flatMap (/usr/local/lib/node_modules/typescript/lib/tsserver.js:498:25)
at Object.getCodeFixesAtPosition (/usr/local/lib/node_modules/typescript/lib/tsserver.js:111663:23)
at IOSession.Session.getCodeFixes (/usr/local/lib/node_modules/typescript/lib/tsserver.js:119225:64)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/usr/local/lib/node_modules/typescript/lib/tsserver.js:118099:61)
at /usr/local/lib/node_modules/typescript/lib/tsserver.js:119389:88
at IOSession.Session.executeWithRequestId (/usr/local/lib/node_modules/typescript/lib/tsserver.js:119380:28)
at IOSession.Session.executeCommand (/usr/local/lib/node_modules/typescript/lib/tsserver.js:119389:33)
at IOSession.Session.onMessage (/usr/local/lib/node_modules/typescript/lib/tsserver.js:119409:35)
at Interface.<anonymous> (/usr/local/lib/node_modules/typescript/lib/tsserver.js:120676:27)
Happens somewhere in this this example
GraphQL.mutation({ email: '' }, args => ({
get register() {
return {} // here
__args: {
email: args.email,
},
},
})).ResultType.return(
<InputForm form={form} submit={data => httpPost({ url: '/api/register', data })}>
Expected behavior:
Actual behavior:
Playground Link:
Related Issues:
@cevek That example doesn't have any unused-label errors, so it wouldn't trigger that code fix to happen. There is probably something else in the document causing a parse error to make one of those foo: properties appear to be a label.
It would helpful for you - you should also dump content of current file when an error throws.
Now it is not possible to understand what version of file it had be
From the tsserver.log, but I don't think it would be helpful for you
{"seq":28937,"type":"request","command":"getCodeFixes","arguments":{"file":"/Users/cody/Dev/nutrition/frontend/Registration.tsx","startLine":15,"startOffset":13,"endLine":15,"endOffset":19,"errorCodes":[7028]}}
I can't see any way this would happen normally. The unused label error is only made in one place and that's when we've definitely parsed a LabeledStatement. I'm wondering if the editor may be asking for codefixes with outdated errors, but that should be fixed (Microsoft/vscode#45785). Let me know if you can find a consistent repro for this.
ok
For whatever it's worth, I inexplicably ran into an error similar to this one, only the test failing was isIdentifier. It turned out that tsc was processing some misplaced transpiled files that webpack had created, and once I got rid of them, everything worked fine.
That said, debugging this wasn't very easy--I was hoping that the --extendedDiagnostics flag would at least emit information on what file tsc was looking at when it crashed, but it didn't. Ah well.
@toolness Any chance you could share the file that was causing the error?
Hmm, so there were actually a bunch of different webpack-generated files that were in the directory, and removing them all fixed things... I could try reproducing the error and share the files if that'd help you track down the bug!
@toolness Thanks!
Ok, I think I narrowed it down to one file that triggered the error, although it is a relatively big one (about 153 KB). Hope this helps!
@toolness The error in that example disappears if I change the package.json from "typescript": "^3.0.3"
to "typescript": "next".
Closing this since I tried both the examples in the issue with seems to be working with typescript@next If there is another repro please open a separate issue for it. Thanks.
Most helpful comment
@toolness The error in that example disappears if I change the package.json from
"typescript": "^3.0.3"to"typescript": "next".