typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Bad error in JSDoc type, crashes hover

Open jakebailey opened this issue 6 months ago • 0 comments

In Herebyfile.mjs, I wrote:

/**
 * @type {{ [K in keyof typeof rawOptions as {} extends Record<K, 1> ? never : K]: typeof rawOptions[K] }}
 */
const options = rawOptions;

Image

This has a spurious error.

But, hovering over K to try and read the error causes a hover, which crashes the server!

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x793171]

goroutine 175 [running]:
github.com/microsoft/typescript-go/internal/ast.(*Node).AsTypeAliasDeclaration(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:1196
github.com/microsoft/typescript-go/internal/checker.(*Checker).getDeclaredTypeOfTypeAlias(0xc002dd5008, 0xc003175428)
	github.com/microsoft/typescript-go/internal/checker/checker.go:22244 +0xd1
github.com/microsoft/typescript-go/internal/checker.(*Checker).tryGetDeclaredTypeOfSymbol(0x847100?, 0xc0043a0b40?)
	github.com/microsoft/typescript-go/internal/checker/checker.go:22083 +0x66
github.com/microsoft/typescript-go/internal/checker.(*Checker).getDeclaredTypeOfSymbol(...)
	github.com/microsoft/typescript-go/internal/checker/checker.go:22069
github.com/microsoft/typescript-go/internal/checker.(*Checker).GetTypeAliasTypeParameters(0xc002dd5008, 0xc003175428)
	github.com/microsoft/typescript-go/internal/checker/checker.go:1144 +0x26
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideHover(0xc008a04c90, {0xc3a0b0, 0xc008b000f0}, {0xc008b14080?, 0xc0002e96b0?}, {0x5be31f?, 0x0?})
	github.com/microsoft/typescript-go/internal/ls/hover.go:147 +0x10c5
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleHover(0xc00011ab60, {0xc3a0b0, 0xc008b000f0}, 0xc008b08240)
	github.com/microsoft/typescript-go/internal/lsp/server.go:531 +0xcd
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x8a7552?, {0xc3a0b0?, 0xc008b000f0?}, 0xc002087088?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:400 +0x125
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:283 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 34
	github.com/microsoft/typescript-go/internal/lsp/server.go:301 +0x82a
[Info  - 9:36:34 AM] Connection to server got closed. Server will restart.

jakebailey avatar May 30 '25 16:05 jakebailey