Skip to content

Fix miss-match in operator precedence in TS vs GO - #63907

Open
Titian Cernicova-Dragomir (dragomirtitian) wants to merge 2 commits into
microsoft:mainfrom
bloomberg:fix-symbol-all-operator-precedence
Open

Fix miss-match in operator precedence in TS vs GO#63907
Titian Cernicova-Dragomir (dragomirtitian) wants to merge 2 commits into
microsoft:mainfrom
bloomberg:fix-symbol-all-operator-precedence

Conversation

@dragomirtitian

Copy link
Copy Markdown
Contributor

Add () to make sure SymbolFlags.All has the same value in TS as it does in GO

Fixes #63906

Copilot AI balanced review requested due to automatic review settings August 20, 2026 10:59
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Aug 20, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Corrects SymbolFlags.All generation so TypeScript matches Go.

Changes:

  • Parenthesizes the Go expression before TypeScript generation.
  • Updates generated enum values.
  • Adds synchronous and asynchronous API regression tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tsc/internal/ast/symbolflags.go Clarifies operator precedence.
packages/typescript/src/enums/symbolFlags.enum.ts Corrects the generated enum expression.
packages/typescript/src/enums/symbolFlags.ts Updates the runtime value to 1073741823.
packages/typescript/test/sync/api.test.ts Adds synchronous regression coverage.
packages/typescript/test/async/api.test.ts Adds asynchronous regression coverage.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@dragomirtitian

Copy link
Copy Markdown
Contributor Author

I also added a script to validate that the GO and TS values match. I can remove from the PR if it's not wanted.

SymbolFlagsGlobalLookup SymbolFlags = 1 << 30 // Flag to signal this is a global lookup
SymbolFlagsAll SymbolFlags = 1<<30 - 1 // All flags except SymbolFlagsGlobalLookup
SymbolFlagsGlobalLookup SymbolFlags = 1 << 30 // Flag to signal this is a global lookup
SymbolFlagsAll SymbolFlags = (1 << 30) - 1 // All flags except SymbolFlagsGlobalLookup. Do not remove () they are needed when the expression is copied to TS.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just fix the code gen? We'll totally make this mistake again

@dragomirtitian Titian Cernicova-Dragomir (dragomirtitian) Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did add a check in the code gen to ensure that the values from GO and the ones in TS agree. Not sure what you mean by fix. We could look for this case in particular, but feels like there might be others. Checking that at the end both JS and GO see the same value seems like the simplest way to ensure this does not happen again, regardless of expression

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe both, since this pattern is common in bit flags?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

gofumpt will remove things, I'm pretty sure; I'm just asking if we can parse this in the enum code gen and then generate it with correct precedence in TS

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's also what I'm suggesting, while still keeping the verification script added for hypothetical other future parsing differences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

[7.1 API] SymbolFlags.All has different value in TS vs GO

4 participants