Skip to content

tsgo: parser nil-pointer panic when a JSDoc @overload tags an anonymous default-export function #63750

Description

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions