Skip to content

Return a missing identifier from parseDecoratedExpression when no class follows - #65496

Merged
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
jakebailey:compiler-fixes/decorator-recovery
Nov 18, 2026
Merged

Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
jakebailey:compiler-fixes/decorator-recovery

Conversation

@jakebailey

@jakebailey Jake Bailey (jakebailey) commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Returning a missing declaration here was incorrect; a declaration is of course not an expression.

Malformed decorators can reach expression parsing without a following
class. Returning a missing declaration puts a non-expression node in
assignment and decorator expression slots.

Use the existing missing identifier recovery node while retaining the
expression diagnostic. Cover recovery in assignments, asynchronous
iteration, and destructuring through compiler baselines.
Copilot AI balanced review requested due to automatic review settings November 14, 2026 02:55
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 14, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 14, 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.

🟢 Approval recommended

No active review issues block approval of the decorated-expression recovery change.

No open issues 🎉

What changed in this PR

This PR corrects error recovery in the native TypeScript parser: malformed decorated expressions now produce a missing identifier rather than a declaration, preserving the expected expression node kind.

Changes:

  • Updates parseDecoratedExpression to return a missing identifier.
  • Adds regression coverage for malformed decorators in assignments, for await loops, and destructuring.
  • Updates diagnostic, emit, type, and symbol baselines to reflect the revised recovery behavior.
File Description
tsc/​testdata/​tests/​cases/​compiler/​decoratorMissingClassExpression.ts Adds malformed decorated-expression regression cases.
tsc/​testdata/​baselines/​reference/​conformance/​decoratorOnFunctionExpression.types Updates recovered function-expression types.
tsc/​testdata/​baselines/​reference/​conformance/​decoratorOnFunctionExpression.symbols Removes the discarded decorator’s symbol entry.
tsc/​testdata/​baselines/​reference/​conformance/​decoratorOnArrowFunction.types Records recovered arrow-function types.
tsc/​testdata/​baselines/​reference/​conformance/​decoratorOnArrowFunction.symbols Records the missing parameter’s symbol.
tsc/​testdata/​baselines/​reference/​conformance/​decoratorOnArrowFunction.js Updates recovered arrow-function emit.
tsc/​testdata/​baselines/​reference/​conformance/​decoratorOnArrowFunction.errors.txt Updates arrow-function recovery diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​decoratorMissingClassExpression.types Adds regression type baselines.
tsc/​testdata/​baselines/​reference/​compiler/​decoratorMissingClassExpression.symbols Adds regression symbol baselines.
tsc/​testdata/​baselines/​reference/​compiler/​decoratorMissingClassExpression.js Adds regression JavaScript emit baselines.
tsc/​testdata/​baselines/​reference/​compiler/​decoratorMissingClassExpression.errors.txt Adds expected regression diagnostics.
tsc/​internal/​parser/​parser.go Returns a missing identifier for invalid decorated expressions.

Review effort: Balanced

@jakebailey Jake Bailey (jakebailey) changed the title Return a missing identifier from parseDecoratedExpression instead of a missing declaration Return a missing identifier from parseDecoratedExpression when no class follows Nov 18, 2026
A decorated expression without a class was the only way a missing
declaration could appear where an expression belongs, including a
for-in or for-of initializer. With that recovery producing a missing
identifier, the for-initializer union, the left-hand-side expression
kinds, operator precedence and the printer's expression emitter no
longer need to account for it.
@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 18, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Nov 18, 2026
Merged via the queue into microsoft:main with commit 62b4f96 Nov 18, 2026
34 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the compiler-fixes/decorator-recovery branch November 18, 2026 17:48
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants