Skip to content

Report operation parameters as op::parameters in type names - #11551

Merged
Timothee Guerin (timotheeguerin) merged 4 commits into
mainfrom
copilot/fix-inaccurate-warning-messages
Aug 28, 2026
Merged

Timothee Guerin (timotheeguerin) merged 4 commits into
mainfrom
copilot/fix-inaccurate-warning-messages

Conversation

Copilot AI commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Diagnostics referencing an operation's parameter printed the anonymous model expression, e.g. TestService.{ param: TestService.Foo }.param, which is neither stable nor traceable back to the operation. getTypeName had no way to resolve the "parent" of a parameters model expression, so it fell back to the generic anonymous-model rendering.

Changes

  • getModelName (packages/compiler/src/core/helpers/type-name-utils.ts): for an anonymous model, first attempt to resolve it as an operation's parameters.
  • New getOperationParametersName: walks the syntax tree (ModelExpression → OperationSignatureDeclaration.parameters → OperationStatement) to render Namespace.op::parameters, including the interface prefix when the operation is on an interface, and op::parameters under nameOnly.
  • Updated expectations in packages/versioning/test/incompatible-versioning.test.ts and the @overload case in packages/compiler/test/decorators/decorators.test.ts; added coverage in type-name-utils.test.ts.

Example

namespace TestService;

@added(Versions.v2)
model Foo {}

op test(param: Foo): void;

Before:

'TestService.{ param: TestService.Foo }.param' is referencing versioned type 'TestService.Foo' but is not versioned itself.

After:

'TestService.test::parameters.param' is referencing versioned type 'TestService.Foo' but is not versioned itself.

This also improves unrelated messages built on the same helper, e.g. @overload mismatches now read Property 'param' is missing on type 'someUnrelatedThing::parameters' but required in 'someThing::parameters'.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

…ameters`

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix inaccurate warning messages regarding incompatible versions Report operation parameters as op::parameters in type names Aug 5, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: bbca6c7

@microsoft-github-policy-service microsoft-github-policy-service Bot added the stale Mark a PR that hasn't been recently updated and will be closed. label Aug 20, 2026
@timotheeguerin Timothee Guerin (timotheeguerin) removed the stale Mark a PR that hasn't been recently updated and will be closed. label Aug 28, 2026
@timotheeguerin
Timothee Guerin (timotheeguerin) marked this pull request as ready for review August 28, 2026 12:49
Copilot AI lite review requested due to automatic review settings August 28, 2026 12:49
@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Improve the name reported for an operation's parameters model expression. Diagnostics now refer to MyService.test::parameters.param instead of MyService.{ param: MyService.Foo }.param.

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

This PR improves diagnostic stability/readability by recognizing anonymous models that represent an operation’s parameters and naming them as Namespace.(Interface.)op::parameters (instead of rendering the anonymous model expression).

Changes:

  • Updated getModelName to detect operation-parameter model expressions and format them as op::parameters (including interface prefix when applicable).
  • Added getOperationParametersName to walk the syntax tree from ModelExpression → OperationSignatureDeclaration.parameters → OperationStatement.
  • Updated/added test expectations and introduced focused unit tests for the new naming behavior; added a Chronus entry for the compiler fix.

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
packages/versioning/test/incompatible-versioning.test.ts Updates expected diagnostics to use op::parameters-based naming.
packages/compiler/test/helpers/type-name-utils.test.ts Adds unit coverage for operation-parameter naming (including interface + nameOnly).
packages/compiler/test/decorators/decorators.test.ts Updates @overload error expectation to reflect new parameter-model naming.
packages/compiler/src/core/helpers/type-name-utils.ts Implements detection/rendering of operation-parameter anonymous models as op::parameters.
.chronus/changes/improve-operation-parameters-type-name-2026-7-5.md Adds changelog entry documenting the compiler diagnostic improvement.

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

Copilot AI review requested due to automatic review settings August 28, 2026 16:25

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

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

Suppressed comments (2)

packages/compiler/test/helpers/type-name-utils.test.ts:67

  • Avoid casting the resolved operation to any here; it bypasses type-checking and can hide errors if resolveTypeReference returns a non-operation type. You can keep this type-safe by asserting the resolved value is an Operation and using non-null assertions for the looked-up parameter.
    const [op] = program.resolveTypeReference("Foo.Bar.test");
    const param = (op as any).parameters.properties.get("param");

packages/compiler/test/helpers/type-name-utils.test.ts:77

  • Avoid casting the resolved operation to any here; it bypasses type-checking and can hide errors if resolveTypeReference returns a non-operation type. You can keep this type-safe by asserting the resolved value is an Operation and using non-null assertions for the looked-up parameter.
    const [op] = program.resolveTypeReference("Foo.test");
    const param = (op as any).parameters.properties.get("param");

Merged via the queue into main with commit 2976f18 Aug 28, 2026
29 checks passed
@timotheeguerin
Timothee Guerin (timotheeguerin) deleted the copilot/fix-inaccurate-warning-messages branch August 28, 2026 17:13
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 lib:versioning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[diagnostics]: inaccurate warning messages regarding incompatible verions

4 participants