Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 9, 2025

  • Analyze TypeScript PR #60304 which fixes ASI (Automatic Semicolon Insertion) issues when emitting return/yield statements
  • Identify the current equivalent function emitExpressionNoASI in the Go port's printer
  • Understand the problem: comments in parenthesized expressions can cause ASI issues when parentheses are removed
  • Map AST node kinds from TypeScript to Go equivalents
  • Enhance emitExpressionNoASI to match the new parenthesizeExpressionForNoAsi logic from TypeScript
  • Apply recursive ASI prevention to PropertyAccess, ElementAccess, Call, TaggedTemplate, PostfixUnary, Binary, Conditional, As, Satisfies, and NonNull expressions
  • Ensure existing printer tests continue to pass
  • Implement proper comment detection in willEmitLeadingNewLine function
  • Test the changes work correctly for the reported ASI issue
  • Update baselines if necessary

Enhanced the emitExpressionNoASI function to recursively process expression structures that could have ASI issues, matching the approach from TypeScript PR #60304. The main improvement is more rigorous parenthesization logic that walks into sub-expressions. However, the willEmitLeadingNewLine function still needs proper comment detection implementation to fully resolve the reported ASI issues.

Fixes #1123.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

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.

Port TypeScript PR #60304: More rigorous ASI prevention when emitting return/yield

2 participants