Skip to content

TSServer getCodeFixes results in Debug Failure. False expression: Token end is child end #51905

@sirikon

Description

@sirikon

Bug Report

Encountered a problem while working with TypeScript on VSCode. The problem is pretty obscure, but it can be reproduced by following these instructions

  1. Clone this repository: https://github.com/sirikon-experiments/tsserver-bug
  2. Inside the repository, with NodeJS 18.12.1, run npm install
  3. Open VSCode on the repository
  4. Open src/helper.ts and keep it in a tab, don't close it.
  5. Open src/main.ts, place the cursor over logContents on line 5 and hit Ctrl + . (Or whatever key combination you use for opening quick fixes).
    5.1. It displays No code actions available.
  6. Open src/models.ts and comment half of the defined keys in the file, lines 15 to 29 for example.
  7. Go back to src/main.ts and try again opening the quick fixes over logContents as before.
    7.1. It displays the quick fixes properly, recommending Add import from "./helper"
  8. Uncommenting lines 15 to 29 in src/models.ts makes the quick fixes disappear again. Another way to make it work in src/main.ts is to change logContents(data); to logContents(); and ask for quick fixes again.
  9. In VSCode: Ctrl + Shift + P -> TypeScript: Open TS Server Log -> You'll see errors like these:
    Debug Failure. False expression: Token end is child end

    Error: Debug Failure. False expression: Token end is child end
        at processChildNode (/home/sirikon/repos/tsserver-bug/node_modules/typescript/lib/tsserver.js:150867:38)
        at /home/sirikon/repos/tsserver-bug/node_modules/typescript/lib/tsserver.js:150803:21
        at visitNode (/home/sirikon/repos/tsserver-bug/node_modules/typescript/lib/tsserver.js:31215:24)
        at forEachChildInPropertySignature (/home/sirikon/repos/tsserver-bug/node_modules/typescript/lib/tsserver.js:31310:17)
        at Object.forEachChild (/home/sirikon/repos/tsserver-bug/node_modules/typescript/lib/tsserver.js:31998:47)
        at processNode (/home/sirikon/repos/tsserver-bug/node_modules/typescript/lib/tsserver.js:150802:20)
        at processChildNode (/home/sirikon/repos/tsserver-bug/node_modules/typescript/lib/tsserver.js:150874:21)
        at processChildNodes (/home/sirikon/repos/tsserver-bug/node_modules/typescript/lib/tsserver.js:150929:48)

🔎 Search Terms

  • "Debug Failure. False expression: Token end is child end"

🕗 Version & Regression Information

Happens, at least, on versions 4.9.4 and 4.9.3, didn't try more versions for now.

🙁 Actual behavior

Given the instructions, the presented scenario results in errors when tsserver is asked for code fixes, but it should work as expected, as everything else.

🙂 Expected behavior

Given the instructions, quick fixes should work always regardless of the amount of keys in a model.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions