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

Crash in JSX tag when spread element is non-structured type

Open DanielRosenwasser opened this issue 2 weeks ago • 1 comments

import React from "@@not-resolved@@"

function SomeOtherComponent(props: any) {
    return (
        <SomeComponent {...props} /**//>
    );
} 

Request completions at the /**/

[error] panic handling requesttextDocument/completionruntime error: invalid memory address or nil pointer dereferencegoroutine 299834 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc0001e4008, 0xc0b8c2bb60)
	github.com/microsoft/typescript-go/internal/lsp/server.go:701 +0x58
panic({0xbeef40?, 0x16eeb70?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/checker.(*StructuredType).Properties(...)
	github.com/microsoft/typescript-go/internal/checker/types.go:814
github.com/microsoft/typescript-go/internal/ls.setMemberDeclaredBySpreadAssignment(0xc0be6ec680?, 0xc09ca0d700, 0xc0b8196c08)
	github.com/microsoft/typescript-go/internal/ls/completions.go:4085 +0x8d
github.com/microsoft/typescript-go/internal/ls.filterJsxAttributes({0x0, 0x0, 0x0}, {0xc0bca96d18, 0x1, 0xc0b8196c08?}, 0xc07b321208, 0x55, 0xc0b8196c08)
	github.com/microsoft/typescript-go/internal/ls/completions.go:4348 +0xe5
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func16()
	github.com/microsoft/typescript-go/internal/ls/completions.go:1538 +0x16d
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func18(...)
	github.com/microsoft/typescript-go/internal/ls/completions.go:1689
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData(0xc0b8c2bc80, {0x10960c8, 0xc0b8c2bc20}, 0xc0b8196c08, 0xc07b321208, 0x55, 0xc00718b700)
	github.com/microsoft/typescript-go/internal/ls/completions.go:1717 +0x1edf
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition(0xc0b8c2bc80, {0x10960c8, 0xc0b8c2bc20}, 0xc07b321208, 0x55, 0x0)
	github.com/microsoft/typescript-go/internal/ls/completions.go:383 +0x2cf
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion(0xc0b8c2bc80, {0x10960c8, 0xc0b8c2bc20}, {0xc0a1899380?, 0xc0b8c2bc20?}, {0xa1899380?, 0xc0?}, 0xc0c040a780)
	github.com/microsoft/typescript-go/internal/ls/completions.go:44 +0xc8
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion(0xc000100808?, {0x10960c8?, 0xc0b8c2bc20?}, 0xc0a1899380?, 0x40b92c?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:1011 +0x39
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].16({0x10960c8, 0xc0b8c2bc20}, 0xc0b8c2bb60)
	github.com/microsoft/typescript-go/internal/lsp/server.go:617 +0x130
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0001e4008, {0x1096100?, 0xc09f0e6640?}, 0xc0b8c2bb60)
	github.com/microsoft/typescript-go/internal/lsp/server.go:501 +0x14b
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:404 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 10
	github.com/microsoft/typescript-go/internal/lsp/server.go:424 +0x9ad

DanielRosenwasser avatar Dec 11 '25 01:12 DanielRosenwasser

Funny aside:

export function ComponentNumber(props: number) {
    return <SomeComponent {...props} /*number*//>;
}
export function ComponentBoolean(props: boolean) {
    return <SomeComponent {...props} /*boolean*//>;
}

/*number*/ crashes, /*boolean*/ does not because it's really a union.

DanielRosenwasser avatar Dec 11 '25 01:12 DanielRosenwasser