Skip to content

Return a missing identifier from parseDecoratedExpression instead of a missing declaration - #65496

Open
Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/decorator-recovery
Open

Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/decorator-recovery

Conversation

@jakebailey

Copy link
Copy Markdown
Member

This 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

This branch has not been deployed

No deployments
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: Not started

Development

Successfully merging this pull request may close these issues.

2 participants