microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.93k stars 12.47k forks source link

TS Server fatal error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isUnaryExpression'. #53638

Closed davidkrammer closed 1 year ago

davidkrammer commented 1 year ago

Type: Bug

❗️❗️❗️ Please fill in the sections below to help us diagnose the issue ❗️❗️❗️

TypeScript Version: 5.0.2

Steps to reproduce crash

1. 2. 3.

TS Server Log

❗️ Server logging disabled. To help us fix crashes like this, please enable logging by setting:

"typescript.tsserver.log": "verbose"

After enabling this setting, future crash reports will include the server log.

TS Server Error Stack

Server: semantic

Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isUnaryExpression'.
    at cast (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:3443:16)
    at Object.parenthesizeOperandOfPrefixUnary (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:21786:50)
    at Object.createPrefixUnaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:23915:41)
    at parsePrefixUnaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33520:32)
    at parseSimpleUnaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33572:16)
    at parseUnaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33554:35)
    at parseBinaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33472:25)
    at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33145:18)
    at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33111:16)
    at doOutsideOfContext (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:30808:12)
    at allowInAnd (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:30829:12)
    at parseExpressionOrLabeledStatement (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34623:24)
    at parseStatement (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34855:12)
    at parseListElement (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31579:12)
    at parseList (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31564:19)
    at parseBlock (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34374:26)
    at parseStatement (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34769:16)
    at parseListElement (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31579:12)
    at parseList (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31564:19)
    at parseBlock (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34374:26)
    at parseStatement (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34769:16)
    at parseListElement (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31579:12)
    at parseList (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31564:19)
    at parseSourceFileWorker (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:30624:24)
    at Object.parseSourceFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:30457:20)
    at createSourceFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:30290:21)
    at createLanguageServiceSourceFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:135139:22)
    at acquireOrUpdateDocument (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:132053:26)
    at Object.acquireDocumentWithKey (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:131978:12)
    at getOrCreateSourceFileByPath (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:135464:31)
    at Object.getOrCreateSourceFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:135444:14)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:135376:42
    at Object.getSourceFileWithCache [as getSourceFile] (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:117127:24)
    at findSourceFileWorker (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:119460:23)
    at findSourceFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:119380:20)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:119329:22
    at getSourceFileFromReferenceWorker (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:119298:26)
    at processSourceFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:119327:5)
    at processRootFile (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:119123:5)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:117908:41
    at forEach (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:2307:22)
    at createProgram (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:117908:5)
    at synchronizeHostData (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:135400:15)
    at Object.getProgram (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:135472:5)
    at ConfiguredProject2.updateGraphWorker (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:172153:41)
    at ConfiguredProject2.updateGraph (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:172090:32)
    at ConfiguredProject2.updateGraph (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:173272:24)
    at _ProjectService.createLoadAndUpdateConfiguredProject (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:174879:13)
    at _ProjectService.assignProjectToOpenedScriptInfo (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:175970:26)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:176250:64
    at flatMap (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:2555:17)
    at _ProjectService.applyChangesInOpenFiles (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:176250:24)
    at updateOpen (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:177395:29)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:179962:69
    at IpcIOSession.executeWithRequestId (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:179954:14)
    at IpcIOSession.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:179962:29)
    at IpcIOSession.onMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:180004:51)
    at process.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:181571:14)
    at process.emit (node:events:526:28)
    at emit (node:internal/child_process:938:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

VS Code version: Code 1.77.0 (Universal) (7f329fe6c66b0f86ae1574c2911b681ad5a45d63, 2023-03-29T09:57:11.797Z) OS version: Darwin arm64 22.3.0 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Apple M1 Max (10 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|3, 3, 3| |Memory (System)|32.00GB (0.20GB free)| |Process Argv|--crash-reporter-id ec8a89b3-780f-47ec-aae4-23337b704627| |Screen Reader|yes| |VM|0%|
Extensions (59) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|3.0.2 project-manager|ale|12.7.0 tailwindshades|bou|0.0.5 vscode-tailwindcss|bra|0.9.11 simple-react-snippets|bur|1.2.7 vscode-expo|byC|0.9.2 gitignore|cod|0.9.0 vscode-eslint|dba|2.4.0 githistory|don|0.6.20 xml|Dot|2.5.1 es7-react-js-snippets|dsz|4.4.3 gitlens|eam|13.4.0 vscode-html-css|ecm|1.13.1 vscode-npm-script|eg2|0.3.29 prettier-vscode|esb|9.10.4 auto-close-tag|for|0.5.14 code-runner|for|0.12.0 copilot|Git|1.78.9758 copilot-labs|Git|0.12.791 vscode-graphql|Gra|0.8.7 vscode-graphql-execution|Gra|0.1.8 vscode-graphql-syntax|Gra|1.1.0 todo-tree|Gru|0.0.224 rest-client|hum|0.25.1 vue|jcb|0.1.5 svg|joc|1.5.2 firebase-explorer|jsa|0.3.3 vscode-colorize|kam|0.11.1 i18n-ally|lok|2.8.1 typescript-auto-compiler|mor|0.7.0 isort|ms-|2022.8.0 python|ms-|2023.6.0 vscode-pylance|ms-|2023.3.40 jupyter|ms-|2023.3.1000892223 jupyter-keymap|ms-|1.1.0 jupyter-renderers|ms-|1.0.15 vscode-jupyter-cell-tags|ms-|0.1.8 vscode-jupyter-slideshow|ms-|0.1.5 remote-ssh|ms-|0.98.0 remote-ssh-edit|ms-|0.84.0 cpptools|ms-|1.15.1 remote-explorer|ms-|0.2.0 vsliveshare|ms-|1.0.5834 vscode-react-native|msj|1.10.2 vetur|oct|0.37.3 material-product-icons|PKi|1.5.0 platformio-ide|pla|3.1.1 vscode-css-peek|pra|4.2.0 prisma|Pri|4.12.0 vscode-rapidapi-client|Rap|1.10.1 vscode-services|rap|1.0.0 LiveServer|rit|5.7.9 ayu|tea|1.0.5 vsfire|tob|1.4.1 vscode-icons|vsc|12.2.0 gitblame|wad|10.1.0 fig|wit|0.0.7 material-theme|zhu|3.15.8 vscode-open-in-github|ziy|1.3.6 (5 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593cf:30376535 pythonvs932:30410667 cppdebug:30492333 vsclangdc:30486549 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 vscccc:30610679 nodejswelcome1:30587005 2e4cg342:30602488 pyind779:30671433 f6dab269:30613381 pythonsymbol12:30671437 a9j8j154:30646983 vsccsb:30677849 pythonb192:30669360 azdwalk:30687957 pythonms35:30701012 ```
mjbvz commented 1 year ago

Duplicate of #53637

Please share code or a small project which causes this issue

RyanCavanaugh commented 1 year ago

@davidkrammer would you be able to post a (redacted if needed) zip file or other way to reproduce this crash? Thanks!