Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

Fix type graph viewer to display scopeless decorator state

Scopeless decorators (e.g., @clientName("enabled") without a scope parameter) store their state using Symbol keys. The type graph viewer's ObjectInspector and ObjectPreview only iterated over string properties via Object.getOwnPropertyNames() and for...in loops, causing Symbol-keyed decorator state to appear empty in both expanded and collapsed views.

Changes:

  • Add Symbol key iteration in object-inspector.tsx using Object.getOwnPropertySymbols()
  • Add Symbol key iteration in object-preview.tsx to show Symbol properties in collapsed view
  • Get all property keys (string and Symbol) upfront and process them together
  • Update getPropertyValue() in property-utils.tsx to accept string | symbol
  • Add Symbol key sorting for consistent display ordering when sortObjectKeys is enabled
  • Remove nested describe blocks in tests per review feedback
  • Add test for Symbol property sorting in object inspector
  • Add tests for Symbol properties in object preview
  • Fix inconsistency in empty string key handling for enumerable and non-enumerable properties

Example:

@clientName("EnabledProperty")  // Scopeless - uses Symbol key
model Example {
  @clientName("isEnabled")      // Now displays in type graph viewer
  enable: true;
}

Previously, the decorator data would render as Symbol(...): { } in both collapsed and expanded views. Now it correctly displays the decorator properties in both the collapsed object preview and the expanded inspector view.

Original prompt

This section details on the original issue you should resolve

<issue_title>Type graph does not contain scopeless clientName</issue_title>
<issue_description>If I specify a @clientName decorator with a different rename value than the property name and no scope, as is supported by documentation for all emitters, the type graph view at least in the Playground does not show a value despite the autorest emitter emitting an x-ms-enum.name correctly:

image

Only if I specify a scope does it show up right. Surely, this is a bug since the emitters need to get it from the type graph. But is it only a bug in the playground? Does this happen if other optional decorator properties aren't specified?

Playground Link</issue_description>

<agent_instructions>In the html program viewer it seems like we are not displaying state entries without a name and so the key is a symbol which seems is skipped</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@timotheeguerin I think this is a bug in the program viewer, when no scope is provided the key is a symbol and seems like we might not be showing those keys

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

import { describe, expect, it } from "vitest";
import { ObjectInspector } from "./object-inspector.js";

describe("ObjectInspector", () => {
Copy link
Member

Choose a reason for hiding this comment

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

@copilot remove top level describe, just keep the content

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 3f44231 - removed the nested describe blocks and kept only the test functions.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot revert those change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The pnpm-workspace.yaml file was not modified in the commits - it appears unchanged in the PR.

}
}

// Also iterate over Symbol keys
Copy link
Member

Choose a reason for hiding this comment

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

@copilot I think this should be simplified. Why not originally list all string and symbol properties

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplified in 3f44231 - now getting all string and Symbol properties upfront using spread operator, then processing them together in a single iteration loop.

Copilot AI changed the title [WIP] Fix bug with scopeless clientName in type graph Fix type graph viewer to display scopeless decorator state Jan 30, 2026
Copilot AI requested a review from timotheeguerin January 30, 2026 21:08
@timotheeguerin
Copy link
Member

/azp run typespec - pr tools

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copy link
Member

Choose a reason for hiding this comment

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

@copilot This is a good start but it doesn't show up in the collapsed object preview, only when expanded, why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in c64db10. The issue was that object-preview.tsx was using a for...in loop which only iterates over enumerable string properties. Updated it to use Object.getOwnPropertyNames() and Object.getOwnPropertySymbols() to include Symbol keys, matching the approach in object-inspector.tsx. Symbol properties now appear in both collapsed and expanded views.

Copy link
Contributor Author

Copilot AI commented Jan 30, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build node /hom�� tput-dir ../../website/src/content/docs/docs/libraries/versioning/reference . .0_tmp_3760/node_modules/pnpm/dist/node-gyp-bin/sh r --no-emit node .0_tmp_3760/nodegenerate-scenarios-summary sh pec/�� lmstxt --output-dir ../../website/src/content/docs/docs/libraries/http/reference node /.bin/sh n --local --verbsh . _modules/pnpm/ditsx ./.scripts/regen-compiler-docs.ts node (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type graph does not contain scopeless clientName

3 participants