Skip to content

Fix inline targets in add-decorator codefixes - #12525

Draft
catalinaperalta wants to merge 1 commit into
microsoft:mainfrom
catalinaperalta:fix/add-decorator-inline-declarations
Draft

catalinaperalta wants to merge 1 commit into
microsoft:mainfrom
catalinaperalta:fix/add-decorator-inline-declarations

Conversation

@catalinaperalta

Copy link
Copy Markdown
Member

Summary

Fix createAddDecoratorCodeFix so declarations sharing a line receive the decorator themselves, rather than decorating the declaration at the start of the line.

  • Insert immediately before an inline target with a separating space.
  • Preserve existing line-start insertion and indentation for multiline declarations.
  • Add regression tests for inline model properties and properties with existing decorators.

This enables Azure/typespec-azure#5946 to reuse the compiler helper instead of duplicating insertion logic, following Azure/typespec-azure#5946 (comment).

Validation

  • Compiler package build passed.
  • Compiler suite: 4,295 passed, 6 existing skips, including the new inline regressions.
  • Changed-file formatting and lint passed.
  • Full Core build was blocked in the VS Code package by a missing @typespec/ts-http-runtime CommonJS logger module.
  • Repository-wide type-aware lint was blocked by a generated tmlanguage.d.ts input/output collision in the compiler tsconfig.

Validation was performed on the compiler revision pinned by the Azure prototype, with this fix applied.

Insert decorators at inline declarations rather than at the start of their containing line. Preserve existing multiline indentation and decorator attachment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: eddbfa67-cd77-4acf-99f6-8fd275d6c7d6
@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Nov 10, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/compiler@12525

commit: b42e910

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Keep add-decorator codefixes on their intended declaration when declarations share a line.

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

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

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant