Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 13, 2026

  • Explore repository structure and understand the codebase
  • Locate relevant files: lib.ts, decorators.ts, package.ts, clients.ts
  • Understand how clientInitialization works
  • Understand test structure in alternate-type.test.ts
  • Add diagnostic warning definition in lib.ts for unused client initialization parameters
  • Add validation function to check if clientInitialization parameters are used in operations
  • Call validation function in package.ts after client hierarchy is created
  • Add comprehensive tests in client-initialization.test.ts
  • Add changeset describing the feature
  • Fix build failures:
    • Fixed TypeScript compilation errors (return type and invalid kind check)
    • Changed from createDiagnostic to reportDiagnostic to ensure diagnostics are properly reported
    • Fixed validation logic to avoid duplicate warnings for inherited parameters
  • All tests passing (82 test files, 1098 tests)
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: no warning on unused client initializer param(s)</issue_title>
<issue_description>### Describe the bug

If clientInitialization.parameters contains values that aren't used in any routes (client or its sub-clients), a diagnostic warning should be produced (maybe even an error as this seems like an authoring mistake).

Reproduction

tcgc version 0.54.0

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.</issue_description>

<agent_instructions>1. Add a linter rule warning definition here https://github.com/Azure/typespec-azure/blob/main/packages/typespec-client-generator-core/src/lib.ts
2. Add verification checks here https://github.com/Azure/typespec-azure/blob/main/packages/typespec-client-generator-core/src/decorators.ts#L1007. If this doesn't work with the test cases later, then add it once the whole client hierarchy is set up
3. Add tests like the one here to check whether a warning is raised https://github.com/Azure/typespec-azure/blob/main/packages/typespec-client-generator-core/test/decorators/alternate-type.test.ts#L199
4. Make sure this works with the @client, @operationGroup, and @clientLocation decorator. For example, make sure the code works if we use @operationGroup decorators to make something a sub client and it has those parameters, that we don't raise a warning.</agent_instructions>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Jan 13, 2026
Copilot AI and others added 2 commits January 13, 2026 20:07
…parameters

Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix no warning on unused client initializer parameters Add warning for unused client initialization parameters Jan 13, 2026
Copilot AI requested a review from iscai-msft January 13, 2026 20:11
@iscai-msft
Copy link
Contributor

@copilot fix build failures

Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 13, 2026

@copilot fix build failures

Fixed in commit 3a28190. The build failures were caused by:

  1. TypeScript compilation error: validation function was returning readonly Diagnostic[] instead of being integrated with the existing diagnostic reporting mechanism
  2. Invalid method kind check: attempted to check for "clientaccessor" which doesn't exist in the SdkMethod type union
  3. Diagnostics not being reported to the program, so tests couldn't see them

Changes made:

  • Switched from createDiagnostic to reportDiagnostic to properly report diagnostics to the program
  • Removed invalid clientaccessor kind check
  • Fixed validation logic to only validate at top-level clients (not recursively) to avoid duplicate warnings for inherited parameters

All 1098 tests now pass including the 8 new tests for unused client initialization parameter warnings.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: no warning on unused client initializer param(s)

2 participants