TypeScript Version: 2.9.2
Can't use ts@next because of #25484 that happens every 5min
Search Terms:
Code
Error: Debug Failure. Did not expect JsxExpression to have an Identifier in its trivia
at addSyntheticNodes (/usr/local/lib/node_modules/typescript/lib/tsserver.js:89462:30)
at createChildren (/usr/local/lib/node_modules/typescript/lib/tsserver.js:89451:9)
at NodeObject.getChildren (/usr/local/lib/node_modules/typescript/lib/tsserver.js:89400:56)
at getTokenAtPositionWorker (/usr/local/lib/node_modules/typescript/lib/tsserver.js:71215:43)
at Object.getTokenAtPosition (/usr/local/lib/node_modules/typescript/lib/tsserver.js:71206:16)
at getInfo (/usr/local/lib/node_modules/typescript/lib/tsserver.js:85133:28)
at Object.getCodeActions (/usr/local/lib/node_modules/typescript/lib/tsserver.js:85095:28)
at /usr/local/lib/node_modules/typescript/lib/tsserver.js:83738:121
at Object.flatMap (/usr/local/lib/node_modules/typescript/lib/tsserver.js:1802:25)
at Object.getFixes (/usr/local/lib/node_modules/typescript/lib/tsserver.js:83738:23)
at /usr/local/lib/node_modules/typescript/lib/tsserver.js:90750:35
at Object.flatMap (/usr/local/lib/node_modules/typescript/lib/tsserver.js:1802:25)
at Object.getCodeFixesAtPosition (/usr/local/lib/node_modules/typescript/lib/tsserver.js:90748:23)
at IOSession.Session.getCodeFixes (/usr/local/lib/node_modules/typescript/lib/tsserver.js:97423:64)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/usr/local/lib/node_modules/typescript/lib/tsserver.js:96250:61)
at /usr/local/lib/node_modules/typescript/lib/tsserver.js:97580:88
at IOSession.Session.executeWithRequestId (/usr/local/lib/node_modules/typescript/lib/tsserver.js:97571:28)
at IOSession.Session.executeCommand (/usr/local/lib/node_modules/typescript/lib/tsserver.js:97580:33)
at IOSession.Session.onMessage (/usr/local/lib/node_modules/typescript/lib/tsserver.js:97600:35)
at Interface.<anonymous> (/usr/local/lib/node_modules/typescript/lib/tsserver.js:98831: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)
Expected behavior:
Actual behavior:
Playground Link:
Related Issues:
tsserver logs id: 1660483066
@cevek Do you have any example code I can use to reproduce the issue?
@andy-ms I don't know how to reproduce this error
@cevek The error happens because some JsxExpression (as in {0} in <Foo attr={0} />) parsed funny and we found an Identifier where one shouldn't exist. The tsserver log (you gave an ID but I don't know how to use that?) might give some indication of the file being scanned. You could also modify the Debug.fail statement in addSyntheticNodes to Debug.fail("For the repro: " + parent.getText()); that should show you the particular one it was failing on.
The tsserver log (you gave an ID but I don't know how to use that?)
I think you should ask about it @mhegazy
@cevek It looks like the error is happening somewhere around <form onSubmit={onSubmit} in Registration.tsx when you were editing it. The error is then triggered when the editor asks for refactors at a certain position. It shouldn't have anything to do with types, just with the text in the file not parsing right and being detected during the call to node.getChildren() in getTokenAtPosition. Next time you see this error, could you take a snapshot of the current file?
Also I have a lot of similar error([email protected]):
Error: Debug Failure. Did not expect JsxSelfClosingElement to have an Identifier in its trivia
at addSyntheticNodes (/usr/local/lib/node_modules/typescript/lib/tsserver.js:110415:30)
at createChildren (/usr/local/lib/node_modules/typescript/lib/tsserver.js:110404:9)
at NodeObject.getChildren (/usr/local/lib/node_modules/typescript/lib/tsserver.js:110348:56)
at getTokenAtPositionWorker (/usr/local/lib/node_modules/typescript/lib/tsserver.js:88795:43)
at getTokenAtPosition (/usr/local/lib/node_modules/typescript/lib/tsserver.js:88787:16)
at Object.findTokenOnLeftOfPosition (/usr/local/lib/node_modules/typescript/lib/tsserver.js:88828:31)
at Object.getSignatureHelpItems (/usr/local/lib/node_modules/typescript/lib/tsserver.js:98753:36)
at Object.getSignatureHelpItems (/usr/local/lib/node_modules/typescript/lib/tsserver.js:111549:37)
at IOSession.Session.getSignatureHelpItems (/usr/local/lib/node_modules/typescript/lib/tsserver.js:119021:62)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/usr/local/lib/node_modules/typescript/lib/tsserver.js:118049:61)
at /usr/local/lib/node_modules/typescript/lib/tsserver.js:119442:88
at IOSession.Session.executeWithRequestId (/usr/local/lib/node_modules/typescript/lib/tsserver.js:119433:28)
at IOSession.Session.executeCommand (/usr/local/lib/node_modules/typescript/lib/tsserver.js:119442:33)
at IOSession.Session.onMessage (/usr/local/lib/node_modules/typescript/lib/tsserver.js:119462:35)
at Interface.<anonymous> (/usr/local/lib/node_modules/typescript/lib/tsserver.js:120735:27)
is there someway to recover from this error (tried restarting ts service)? When this happens, the only way I can seemly fix it is to reload vscode... This is especially a pain because I am typically using integrated terminals for my dev server and have to restart them
@ChuckJonas If you know what file you were editing when the crash happened, it's possible you could reproduce the error with just that file's text -- regardless of compile errors. Having text that reproduces this error would help us to fix this.
@ChuckJonas you can restart tsserver by vscode command: TypeScript: restart tsserver
@andy-ms I've tried to come up with a reproducible example multiple times but I can't seem to get consistent results. Next time it happens I'll submit a file. It's also weird that it doesn't seem to happen with extensions disabled (at least not in the hour or so I worked with no extensions). However, the crash is on typescript so IDK how another extension could cause it.
@cevek that actually doesn't work (trust me, I've tried a million times). It won't recover from this error.
FYI: Here is the issue I originally opened https://github.com/Microsoft/vscode/issues/49170
Echoing in that I am also receiving this. It's on a private project, so sharing the code is not possible.
This ts error is in combination with syntax highlighting errors, which leads me to believe that there are experimental language features we're using which create-react-app can transpile perfectly, but vscode's typescript chokes on.
by the way, yarn tsc compiles without error in this project of mine which is showing the JsxExpression error
This ts error is in combination with syntax highlighting errors, which leads me to believe that there are experimental language features we're using which create-react-app can transpile perfectly, but vscode's typescript chokes on.
Do you know what babel plugins you depend on?
@weswigham we're in an unejected create-react-app project, so the list of babel plugins is restricted to these
Hm. Do you know offhand if you use any syntactic stage3 proposals we don't yet support, like the private fields proposal (# properties), or stage1 proposals like do expressions, generator arrows =>*, optional chaining (.?), pipeline (|>), nullish coalesce (??), or extra export forms export * as bar from "foo"?
I don't believe we have any of those @weswigham. Although at this point my propensity for debugging all this is weak, so I'll chime out here. Thank you for the start :)
Assigning to @weswigham since he has looked into it and duplicate #27877 is also assigned to him.
Getting a lot of telemetry for this one (TS >= 3.2, Code >= 1.31).
We still need a way to reproduce this
Sorry, no repo steps but here are some additional stack traces from TS 3.4.3:
Error: Debug Failure. Did not expect JsxExpression to have an Identifier in its trivia
at addSyntheticNodes (tsserver.js:119944:30)
at createChildren (tsserver.js:119933:9)
at NodeObject.getChildren (tsserver.js:119877:56)
at getTokenAtPositionWorker (tsserver.js:95739:43)
at Object.getTokenAtPosition (tsserver.js:95731:16)
at getInfo (tsserver.js:116579:28)
at Object.getAvailableActions (tsserver.js:116563:28)
at tsserver.js:111638:128
at getIterator (tsserver.js:625:23)
at Object.flatMapIterator (tsserver.js:608:27)
at Object.getApplicableRefactors (tsserver.js:111637:36)
at Object.getApplicableRefactors (tsserver.js:121486:32)
at IOSession.Session.getApplicableRefactors (tsserver.js:130230:53)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:129054:61)
at tsserver.js:130454:88
at IOSession.Session.executeWithRequestId (tsserver.js:130445:28)
at IOSession.Session.executeCommand (tsserver.js:130454:33)
at IOSession.Session.onMessage (tsserver.js:130476:35)
...
Error: Debug Failure. Did not expect JsxExpression to have an Identifier in its trivia
at addSyntheticNodes (tsserver.js:119944:30)
at createChildren (tsserver.js:119933:9)
at NodeObject.getChildren (tsserver.js:119877:56)
at getTokenAtPositionWorker (tsserver.js:95739:43)
at Object.getTokenAtPosition (tsserver.js:95731:16)
at getInfo (tsserver.js:116579:28)
at Object.getAvailableActions (tsserver.js:116563:28)
at tsserver.js:111638:128
at getIterator (tsserver.js:625:23)
at Object.flatMapIterator (tsserver.js:608:27)
at Object.getApplicableRefactors (tsserver.js:111637:36)
at Object.getApplicableRefactors (tsserver.js:121486:32)
at IOSession.Session.getApplicableRefactors (tsserver.js:130230:53)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:129054:61)
at tsserver.js:130454:88
at IOSession.Session.executeWithRequestId (tsserver.js:130445:28)
at IOSession.Session.executeCommand (tsserver.js:130454:33)
at IOSession.Session.onMessage (tsserver.js:130476:35)
...
Error: Debug Failure. Did not expect JsxExpression to have an Identifier in its trivia
at addSyntheticNodes (tsserver.js:119944:30)
at createChildren (tsserver.js:119933:9)
at NodeObject.getChildren (tsserver.js:119877:56)
at getTokenAtPositionWorker (tsserver.js:95739:43)
at getTokenAtPosition (tsserver.js:95731:16)
at Object.findTokenOnLeftOfPosition (tsserver.js:95772:31)
at Object.getSignatureHelpItems (tsserver.js:106267:36)
at Object.getSignatureHelpItems (tsserver.js:121081:37)
at IOSession.Session.getSignatureHelpItems (tsserver.js:130027:62)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:128933:61)
at tsserver.js:130454:88
at IOSession.Session.executeWithRequestId (tsserver.js:130445:28)
at IOSession.Session.executeCommand (tsserver.js:130454:33)
...
this happens consistently when doing TSX, like this (in order):
// start with a React.ReactNode expecting result
const extra = useMemo(() => {
return |
}, [])
then try to do some conditionals using { and } in a weird way, like type the element then put it inside {} like:
const extra = useMemo(() => {
return <div>{ <entry> }</div>
}, [])
then try to do the ternary expression
const extraMemo = useMemo(() => {
return <div>{ extra.length ? extra.map((item) => <entry item={item} />) : null }</div>
}, [extra]) // extra = array of strings
the error should pop up. the provider will fail forever to properly parse JSX unless you restart it. it happens so often and I'm currently on:
[2019-05-08 18:58:37.813] [exthost] [error] Error: TypeScript Server Error (3.5.0-dev.20190507)
Debug Failure. Did not expect JsxExpression to have an Identifier in its trivia
Error: Debug Failure. Did not expect JsxExpression to have an Identifier in its trivia
at addSyntheticNodes (tsserver.js:120446:30)
at createChildren (tsserver.js:120435:9)
at NodeObject.getChildren (tsserver.js:120379:56)
at getTokenAtPositionWorker (tsserver.js:96428:43)
at Object.getTokenAtPosition (tsserver.js:96420:16)
at getInfo (tsserver.js:117048:28)
at Object.getAvailableActions (tsserver.js:117032:28)
at tsserver.js:112350:128
at getIterator (tsserver.js:625:23)
at Object.flatMapIterator (tsserver.js:608:27)
at Object.getApplicableRefactors (tsserver.js:112349:36)
at Proxy.getApplicableRefactors (tsserver.js:121972:32)
at IOSession.Session.getApplicableRefactors (tsserver.js:130718:53)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:129542:61)
at tsserver.js:130942:88
at IOSession.Session.executeWithRequestId (tsserver.js:130933:28)
at IOSession.Session.executeCommand (tsserver.js:130942:33)
at IOSession.Session.onMessage (tsserver.js:130964:35)
at Interface.<anonymous> (tsserver.js:132255:27)
at Interface.emit (events.js:182:13)
at Interface._onLine (readline.js:290:10)
at Interface._normalWrite (readline.js:433:12)
at Socket.ondata (readline.js:149:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:279:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at Pipe.onread (net.js:636:20)
at Function.create (f:\Users\Paulo\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\typescript-language-features\dist\extension.js:1:176343)
at v.dispatchResponse (f:\Users\Paulo\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\typescript-language-features\dist\extension.js:1:181711)
at v.dispatchMessage (f:\Users\Paulo\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\typescript-language-features\dist\extension.js:1:180463)
at constructor._reader.onData.e (f:\Users\Paulo\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\typescript-language-features\dist\extension.js:1:179819)
at u.fire (f:\Users\Paulo\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:47:720)
at t.Reader.onLengthData (f:\Users\Paulo\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\typescript-language-features\dist\extension.js:1:185692)
at Socket.t.Reader.constructor.e.on.e (f:\Users\Paulo\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\typescript-language-features\dist\extension.js:1:185340)
at Socket.emit (events.js:182:13)
at Socket.EventEmitter.emit (domain.js:442:20)
at addChunk (_stream_readable.js:279:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at Pipe.onread (net.js:636:20)
@pocesar could you possibly record, eg, a gif of typing in the expression in such a way as to trigger the error? I'm trying to follow your directions and can't seem to trigger the crash - so I must be missing some important nuance.
Here's a simple repo that I see using that ts version:
|:import * as React from 'react'
const a = <div>{<div />|}</div>
x so that the code becomes:import * as React from 'react'
const a = <div>{<div />x}</div>
@mjbvz THANK YOU! π Hopefully fixing that one fixes the rest too
I can consistently reproduce this. The project below may be too hard to decipher for a simple reproduction but thought may be worth sharing here anyway.
Repo: https://github.com/patrickmichalina/fusing-angular/tree/v4 (v4 branch)
npm i
npm run build.desktop.prod
(node:54065) UnhandledPromiseRejectionWarning: Error: Debug Failure. Did not expect JsxExpression to have an Identifier in its trivia
at addSyntheticNodes (/Users/patrick/Repos/fusing-angular-2/node_modules/typescript/lib/typescript.js:116700:30)
at createChildren (/Users/patrick/Repos/fusing-angular-2/node_modules/typescript/lib/typescript.js:116689:9)
at NodeObject.getChildren (/Users/patrick/Repos/fusing-angular-2/node_modules/typescript/lib/typescript.js:116633:56)
at Function.getCompilerChildren (/Users/patrick/Repos/fusing-angular-2/node_modules/ts-morph/dist/ts-morph.js:5575:21)
at getCompilerDescendantsIterator (/Users/patrick/Repos/fusing-angular-2/node_modules/ts-morph/dist/ts-morph.js:12434:40)
at getCompilerDescendantsIterator.next (<anonymous>)
at getCompilerDescendantsIterator (/Users/patrick/Repos/fusing-angular-2/node_modules/ts-morph/dist/ts-morph.js:12436:16)
at getCompilerDescendantsIterator.next (<anonymous>)
at getCompilerDescendantsIterator (/Users/patrick/Repos/fusing-angular-2/node_modules/ts-morph/dist/ts-morph.js:12436:16)
at getCompilerDescendantsIterator.next (<anonymous>)
This command builds an electron application. This is the only target that has this issue. When I remove random code from src/electron/app.ts it goes away. But the code I remove doesn't appear to have a pattern. I cannot pinpoint what code is breaking it.
@patrickmichalina this bug was fixed In TypeScript 3.6. It looks like your project is using 3.2.1.
@andrewbranch OK Thanks. Unfortunately I will have to wait for Angular to support TS v3.6+, since their ngc compiler fails with this newer version.
TS 3.6.2 hinted at spread operators causing issues. So I did some code changes and found that changing the structure fixed the issue even in TS 3.5.2.
// before (this caused the failure)
const lg: Logger = pinoms({
streams: [
...(!isDev ? [] : [ // <==== Think it is this line.
{ level: 'trace', stream: pinoms.prettyStream() },
{ level: 'trace', stream: fileOutStream('trace') }
]),
{ level: 'info', stream: fileOutStream('info') },
{ level: 'warn', stream: fileOutStream('warn') },
{ level: 'error', stream: fileOutStream('error') },
{ level: 'fatal', stream: fileOutStream('fatal') }
]
}) as Logger
// after, compiles just fine.
const devlogs = isDev ? [
{ level: 'trace', stream: pinoms.prettyStream() },
{ level: 'trace', stream: fileOutStream('trace') }
] : []
const lg: Logger = pinoms({
streams: [
...devlogs,
{ level: 'info', stream: fileOutStream('info') },
{ level: 'warn', stream: fileOutStream('warn') },
{ level: 'error', stream: fileOutStream('error') },
{ level: 'fatal', stream: fileOutStream('fatal') }
]
}) as Logger
My issue appears to be fixed. I just wanted to leave this here for future reference. Thanks.