Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 8, 2025

Fix crash in VSCode: Unhandled case in Node.ElementList: KindTupleType

Summary

Fixed a crash that occurred when using TypeScript inlay hints with tuple types. The crash happened when the language server tried to display type information for parameters with tuple types like [string][].

Plan

  • Understand the issue: ElementList() method doesn't handle KindTupleType
  • Add KindTupleType case to ElementList() method in internal/ast/ast.go
  • Create a fourslash test to reproduce the issue
  • Run the test to verify it fails before the fix (confirmed with baseline creation)
  • Apply the fix
  • Verify the test passes after the fix
  • Run linters and existing tests to ensure no regressions
  • Run codeql checker for security validation
  • Address PR feedback: Move test from gen to tests directory

Changes Made

  1. Fixed ElementList() in internal/ast/ast.go: Added handling for KindTupleType by returning the Elements field from TupleTypeNode
  2. Added test TestInlayHintsTupleTypeCrash: Reproduces the original issue with tuple types in inlay hints (now in internal/fourslash/tests/)
  3. Generated baseline files: Showing the fix works correctly and displays type hints for tuple types

Testing & Validation

✅ Test passes in new location
✅ All existing tests pass
✅ Linting passes - 0 issues
✅ Formatting check passes
✅ CodeQL security check - no issues found

Original prompt

This section details on the original issue you should resolve

<issue_title>Crash in VSCode: Unhandled case in Node.ElementList: KindTupleType</issue_title>
<issue_description>## Stack trace

[Error - 7:18:48 PM] Request textDocument/inlayHint failed.
  Message: InternalError: panic handling request textDocument/inlayHint: Unhandled case in Node.ElementList: KindTupleType
  Code: -32603 
panic handling request textDocument/inlayHint Unhandled case in Node.ElementList: KindTupleType goroutine 278400 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x64
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0x14000000f00, 0x140f4912d20)
	github.com/microsoft/typescript-go/internal/lsp/server.go:571 +0x44
panic({0x10528cb00?, 0x1407513e710?})
	runtime/panic.go:783 +0x120
github.com/microsoft/typescript-go/internal/ast.(*Node).ElementList(0x0?)
	github.com/microsoft/typescript-go/internal/ast/ast.go:1073 +0xf8
github.com/microsoft/typescript-go/internal/ast.(*Node).Elements(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:1077
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).getInlayHintLabelParts.func1(0x14046d7a040)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:524 +0x4524
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).getInlayHintLabelParts(0x14003c489e8?, 0x1408f0b0380?)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:745 +0x90
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).typeToInlayHintParts(0x140bfb36000, 0x104fdd56c?)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:313 +0x50
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).getParameterDeclarationTypeHints(0x140bfb36000, 0x1052ffba0?)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:304 +0x84
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).addParameterTypeHint(0x140bfb36000, 0x14089784f50, 0x1408ea4b260)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:280 +0x50
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).visitFunctionLikeForParameterType(0x140bfb36000, 0x140bf3e41e0)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:266 +0xd8
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).visit(0x140bfb36000, 0x140bf3e41e0)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:94 +0x2e8
github.com/microsoft/typescript-go/internal/ast.visitNodes(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:28
github.com/microsoft/typescript-go/internal/ast.visitNodeList(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:37
github.com/microsoft/typescript-go/internal/ast.(*CallExpression).ForEachChild(0x140bd532c60, 0x1407513e500)
	github.com/microsoft/typescript-go/internal/ast/ast.go:6849 +0x114
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).visit(0x140bfb36000, 0x140bd532c60)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:101 +0x390
github.com/microsoft/typescript-go/internal/ast.visit(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:21
github.com/microsoft/typescript-go/internal/ast.(*ExpressionStatement).ForEachChild(0x14000091808?, 0x1407513e4e0?)
	github.com/microsoft/typescript-go/internal/ast/ast.go:3637 +0x34
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).visit(0x140bfb36000, 0x14181e50d80)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:101 +0x390
github.com/microsoft/typescript-go/internal/ast.visitNodes(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:28
github.com/microsoft/typescript-go/internal/ast.visitNodeList(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:37
github.com/microsoft/typescript-go/internal/ast.(*Block).ForEachChild(0x14089784ee0?, 0x1407513e4e0)
	github.com/microsoft/typescript-go/internal/ast/ast.go:3681 +0x74
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.(*inlayHintState).visit(0x140bfb36000, 0x14172841e60)
	github.com/microsoft/typescript-go/internal/ls/inlay_hints.go:101 +0x390
github.com/microsoft/typescript-go/internal/ast.visit(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:21
github.com/microsoft/typescript-go/internal/ast.(*FunctionDeclaration).ForEachChild(0x141af1eda20, 0x1407513e4a0)
	github.com/microsoft/typescript-go/internal/ast/ast.go:4106 +0x1a0
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.(*inlayHint...

</details>

- Fixes microsoft/typescript-go#2039

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix crash in VSCode for unhandled case in Node.ElementList Fix panic in inlay hints for tuple types Nov 8, 2025
Copilot finished work on behalf of jakebailey November 8, 2025 03:59
Copilot AI requested a review from jakebailey November 8, 2025 03:59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this file should be in the tests dir; gen is just for generated tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to internal/fourslash/tests/ in 5dd6ebe

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI requested a review from jakebailey November 8, 2025 04:11
Copilot finished work on behalf of jakebailey November 8, 2025 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants