Skip to content

Port "Fix ASI after get/set keyword" #1055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Jun 4, 2025

@Copilot Copilot AI review requested due to automatic review settings June 4, 2025 21:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ports the fix for Automatic Semicolon Insertion after get/set keywords from the upstream TypeScript PR.

  • Updates test baselines (JS and error files) in the conformance submodule to validate the new syntax for get/set keywords.
  • Adjusts parser logic in internal/parser/parser.go to handle get/set keywords separately from the static modifier.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
testdata/baselines/reference/submodule/conformance/canFollowGetSetKeyword.js.diff Updates test baselines for class and object declarations using get/set keywords.
testdata/baselines/reference/submodule/conformance/canFollowGetSetKeyword.js Reflects valid usage of get/set in class and object definitions.
testdata/baselines/reference/submodule/conformance/canFollowGetSetKeyword.errors.txt.diff Removes previously expected errors due to shorthand property issues with get/set.
testdata/baselines/reference/submodule/conformance/canFollowGetSetKeyword.errors.txt Updates error baseline matching the new parser behavior for get/set usage.
internal/parser/parser.go Refactors token handling to route get/set keywords through a dedicated check.
Comments suppressed due to low confidence (1)

internal/parser/parser.go:3969

  • [nitpick] Consider adding documentation for this function to clarify its purpose and delineate how its allowed tokens differ from those checked in canFollowModifier().
func (p *Parser) canFollowGetOrSetKeyword() bool {

@@ -3906,9 +3906,12 @@ func (p *Parser) nextTokenCanFollowModifier() bool {
return p.canFollowExportModifier()
case ast.KindDefaultKeyword:
return p.nextTokenCanFollowDefaultKeyword()
case ast.KindStaticKeyword, ast.KindGetKeyword, ast.KindSetKeyword:
case ast.KindStaticKeyword:
p.nextToken()
return p.canFollowModifier()
Copy link
Preview

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding a comment explaining why get and set keywords are handled separately from static, to improve clarity for future maintainers.

Suggested change
return p.canFollowModifier()
return p.canFollowModifier()
// `get` and `set` are contextual keywords that require specific validation logic
// to determine their role in the syntax (e.g., as accessors or other constructs).

Copilot uses AI. Check for mistakes.

@jakebailey jakebailey added this pull request to the merge queue Jun 4, 2025
Merged via the queue into microsoft:main with commit f2e0063 Jun 4, 2025
23 checks passed
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.

2 participants