tsgo (the native compiler's parser) panics with a nil pointer dereference when a JSDoc @overload tag is attached to an anonymous default-export function declaration; the JS tsc 6.0.3 handles the same input cleanly.
Minimal repro
Run go test ./internal/parser/ -run TestJSDocOverloadAnonDefaultExport in the native compiler tree:
package parser
import (
"testing"
"github.com/microsoft/typescript-go/internal/ast"
"github.com/microsoft/typescript-go/internal/core"
)
func TestJSDocOverloadAnonDefaultExport(t *testing.T) {
t.Parallel()
text := "/** @overload */\nexport default function () {}\n"
_ = ParseSourceFile(ast.SourceFileParseOptions{FileName: "/a.js", Path: "/a.js"}, text, core.ScriptKindJS)
}
Panics with invalid memory address or nil pointer dereference. The same input also panics through the CLI with allowJs (no checkJs): https://github.com/johnsoncodehk/tsgo-jsdoc-overload-crash
Stack
github.com/microsoft/typescript-go/internal/ast.IsIdentifier(...)
internal/ast/ast_generated.go:638
github.com/microsoft/typescript-go/internal/parser.(*Parser).checkNonIdentifierName(...)
internal/parser/reparser.go:42
github.com/microsoft/typescript-go/internal/parser.(*Parser).reparseJSDocSignature(...)
internal/parser/reparser.go:147
github.com/microsoft/typescript-go/internal/parser.(*Parser).reparseUnhosted(...)
internal/parser/reparser.go:137
Notes (each verified by removal):
- The
@overload must tag an anonymous default-export function; a named declaration (export default function foo () {}) does not panic.
allowJs alone is sufficient (checkJs not required).
Environment
@typescript/native-preview@7.0.0-dev.20260707.2; also reproduces on the native tree typescript/v7.0.2 (2bd066d87) and current main @ dcfc50b3 (2026-08-13)
- tsc (JS): 6.0.3 (clean, no panic)
tsgo(the native compiler's parser) panics with a nil pointer dereference when a JSDoc@overloadtag is attached to an anonymous default-export function declaration; the JStsc6.0.3 handles the same input cleanly.Minimal repro
Run
go test ./internal/parser/ -run TestJSDocOverloadAnonDefaultExportin the native compiler tree:Panics with
invalid memory address or nil pointer dereference. The same input also panics through the CLI withallowJs(nocheckJs): https://github.com/johnsoncodehk/tsgo-jsdoc-overload-crashStack
Notes (each verified by removal):
@overloadmust tag an anonymous default-export function; a named declaration (export default function foo () {}) does not panic.allowJsalone is sufficient (checkJsnot required).Environment
@typescript/native-preview@7.0.0-dev.20260707.2; also reproduces on the native treetypescript/v7.0.2(2bd066d87) and currentmain@dcfc50b3(2026-08-13)