Skip to content

fix(frontend): handle computed property names safely and prevent AST text panics - #29

Merged
phamtanminhtien merged 1 commit into
mainfrom
fix/computed-property-names-ast
Sep 25, 2026
Merged

phamtanminhtien merged 1 commit into
mainfrom
fix/computed-property-names-ast

Conversation

@phamtanminhtien

Copy link
Copy Markdown
Contributor

Summary

This PR hardens AST member name extraction across the TypeScript frontend to safely handle computed property names and unknown AST nodes without panicking.

Changes

  • syntaxMemberName hardening: Add panic recovery guard and handle string/numeric literal computed expressions (internal/typescriptgo/syntax_stmt_class.go).
  • Replace direct .Name().Text() calls: Use syntaxMemberName across TypeAliasDeclaration, UnionType, function parameter types, object literals, and destructuring patterns (syntax_stmt.go, syntax.go, syntax_expr.go, syntax_destruct.go).
  • Tests:
    • Add unit test TestCheckSupportsComputedPropertyNameInTypes in internal/typescriptgo/parse_test.go.
    • Add corpus test case computed_property_types.ts under internal/compiler/testdata/corpus/types/.
  • Documentation: Synchronize docs/typescript-parity-report.md.

…text panics

- Harden syntaxMemberName with panic recovery and support for string/numeric literal computed property expressions.
- Replace unsafe member.Name().Text() calls with syntaxMemberName in type alias signatures, union type signatures, function parameter types, object literals, and destructuring patterns.
- Add unit test TestCheckSupportsComputedPropertyNameInTypes in internal/typescriptgo/parse_test.go.
- Add corpus test case computed_property_types.ts under internal/compiler/testdata/corpus/types/.
- Update docs/typescript-parity-report.md with computed property name support.
@phamtanminhtien
phamtanminhtien merged commit 88c3b1f into main Sep 25, 2026
7 checks passed
@phamtanminhtien
phamtanminhtien deleted the fix/computed-property-names-ast branch September 25, 2026 01:46
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.

1 participant