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

Type: Bug

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

TypeScript Version: 5.1.0-dev.20230304

Steps to reproduce crash

  1. Open up visual studio

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 (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:3440:16)
    at Object.parenthesizeOperandOfPrefixUnary (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:21770:50)
    at Object.createPrefixUnaryExpression (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:23899:41)
    at parsePrefixUnaryExpression (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33504:32)
    at parseSimpleUnaryExpression (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33556:16)
    at parseUnaryExpressionOrHigher (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33538:35)
    at parseBinaryExpressionOrHigher (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33456:25)
    at parseAssignmentExpressionOrHigher (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33129:18)
    at parseExpression (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:33095:16)
    at doOutsideOfContext (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30792:12)
    at allowInAnd (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30813:12)
    at parseExpressionOrLabeledStatement (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:34607:24)
    at parseStatement (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:34839:12)
    at parseListElement (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:31563:12)
    at parseList (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:31548:19)
    at parseSourceFileWorker (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30608:24)
    at Object.parseSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30441:20)
    at createSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:30274:21)
    at createLanguageServiceSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135181:22)
    at acquireOrUpdateDocument (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:132099:26)
    at Object.acquireDocumentWithKey (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:132024:12)
    at getOrCreateSourceFileByPath (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135505:31)
    at Object.getOrCreateSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135485:14)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135417:42
    at Object.getSourceFileWithCache [as getSourceFile] (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:117176:24)
    at findSourceFileWorker (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119508:23)
    at findSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119428:20)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119377:22
    at getSourceFileFromReferenceWorker (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119346:26)
    at processSourceFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119375:5)
    at processRootFile (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:119171:5)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:117956:41
    at forEach (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:2307:22)
    at createProgram (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:117956:5)
    at synchronizeHostData (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135441:15)
    at Object.getProgram (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:135513:5)
    at ConfiguredProject2.updateGraphWorker (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:172332:41)
    at ConfiguredProject2.updateGraph (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:172269:32)
    at ConfiguredProject2.updateGraph (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:173487:24)
    at _ProjectService.createLoadAndUpdateConfiguredProject (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:175098:13)
    at _ProjectService.assignProjectToOpenedScriptInfo (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:176189:26)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:176469:64
    at flatMap (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:2555:17)
    at _ProjectService.applyChangesInOpenFiles (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:176469:24)
    at updateOpen (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:177617:29)
    at c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:180167:69
    at IpcIOSession.executeWithRequestId (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:180159:14)
    at IpcIOSession.executeCommand (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:180167:29)
    at IpcIOSession.onMessage (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:180209:51)
    at process.<anonymous> (c:\Users\Bruger\.vscode\extensions\ms-vscode.vscode-typescript-next-5.1.20230304\node_modules\typescript\lib\tsserver.js:181777: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.76.0 (92da9481c0904c6adfe372c12da3b7748d74bdcb, 2023-03-01T10:22:44.506Z) OS version: Windows_NT x64 10.0.22621 Modes: Sandboxed: No

System Info
Item Value
CPUs AMD Ryzen 7 5800X 8-Core Processor (16 x 3800)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
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) undefined
Memory (System) 31.93GB (18.80GB free)
Process Argv –folder-uri file:///c%3A/Coding/MadegoConsumerApp --crash-reporter-id 0751c08f-edc1-48a4-8acc-5ac0ff5a8c75
Screen Reader no
VM 40%
Extensions (38)
Extension Author (truncated) Version
vscode-sql-formatter adp 1.4.4
vscode-color ans 0.4.5
heroicons-preview BBu 1.0.0
vscode-intelephense-client bme 1.9.5
vscode-tailwindcss bra 0.9.7
multi-cursor-case-preserve Car 1.0.5
json-tree-view Cha 2.6.0
path-intellisense chr 2.8.4
javascript-ejs-support Dig 1.3.3
netcore-snippets dog 3.15.2
xml Dot 2.5.1
es7-react-js-snippets dsz 4.4.3
gitlens eam 13.3.1
vscode-html-css ecm 1.13.1
prettier-vscode esb 9.10.4
auto-rename-tag for 0.1.10
vscode-mysql for 0.4.1
vscode-chatgpt gen 3.9.4
copilot Git 1.77.9225
vscode-pull-request-github Git 0.58.2
bootstrap5-snippets Han 1.2.5
rest-client hum 0.25.1
mysql-syntax jak 1.3.1
dupchecker jia 0.1.7
sequelize-snippets kvc 1.0.0
font-awesome-codes-css med 0.1.1
vscode-typescript-next ms- 5.1.20230304
vsliveshare ms- 1.0.5832
sftp Nat 1.16.2
material-icon-theme PKi 4.24.0
vscode-css-peek pra 4.2.0
tpl-lang qiq 0.0.1
vscode-thunder-client ran 2.5.0
asp-classic-support-v2 SUR 0.7.1
Web-VSCode-Extensions Syn 20.4.48
msbuild-project-tools tin 0.4.9
vscode-import-cost wix 3.3.0
html-css-class-completion Zig 1.20.0
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vsclangdf:30486550
c4g48928:30535728
dsvsc012:30540252
pynewext54:30669237
azure-dev_surveyone:30548225
pyindex848:30662994
nodejswelcome1cf:30587006
3biah626:30602489
pyind779:30671433
89544117:30613380
pythonsymbol12:30671437
vsccsb:30677849

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 16 (11 by maintainers)

Most upvoted comments

I have the same issue. For me is a expo/react-native project. I cannot share the code - other projects to works fine, this started happening after updating to last version of vscode.

Oh, this is because of #52667.

Yay, both crashes are my fault!

@RyanCavanaugh

npx create-react-app test-app --template expo-template-tabs
cd test-app
eas update --auto
ls -al ./dist

Note the the dist folder is the issue here. (as noted in this related post https://github.com/microsoft/TypeScript/issues/53637#issuecomment-1494634775)

archive.tar.gz

We’re tracking this at #53637 and really need a repro! Please help!

@stefan520 I had to download an older version, for me January version works fine https://code.visualstudio.com/updates/v1_77