Skip to content

[TCGC] Add InitializedBy.none to support omitting generated client constructors#3877

Merged
iscai-msft merged 7 commits intomainfrom
copilot/add-none-to-initializedby-enum
Feb 2, 2026
Merged

[TCGC] Add InitializedBy.none to support omitting generated client constructors#3877
iscai-msft merged 7 commits intomainfrom
copilot/add-none-to-initializedby-enum

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Plan to add None to InitializedBy enum

  • Explore repository structure and understand the codebase
  • Add None value (0) to InitializedBy enum in lib/decorators.tsp
  • Update InitializedByFlags enum in src/interfaces.ts to include None = 0 and change Default = -1
  • Update validation logic in src/decorators.ts to accept value 0 for None
  • Fix falsy check in src/clients.ts to use !== undefined instead of truthy check
  • Add validation bypass for None in client type validation
  • Add tests for the new None initialization type
  • Build the package and verify changes
  • Run tests to ensure everything works correctly
  • Add changelog entry
  • Address code review feedback with improved documentation
  • Format code using prettier
  • Regenerate changeset using pnpm -w change add command
Original prompt

This section details on the original issue you should resolve

<issue_title>tcgc: add None to InitializedBy enum</issue_title>
<issue_description>### Clear and concise description of the problem

There is an uncommon need (storage needs it) to indicate that client constructors should be omitted (i.e. they will be hand-written for some reason). Please add None to the InitializedBy enum passed to ClientInitializationOptions so tsp authors can express this.

Checklist

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

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

@vincenttran-msft Slight nit: It would be preferable if we could disable constructors but still get the generated options bag. This is mostly to remove the necessity to do a hand-edit to update the default `version` that ships, when that really should come straight from the generated code.
/// Options used when creating a `BlobClient`
#[derive(Clone, SafeDebug)]
pub struct BlobClientOptions {
    /// Allows customization of the client.
    pub client_options: ClientOptions,
    /// Specifies the version of the operation to use for this request.
    pub version: String,
}

impl Default for BlobClientOptions {
    fn default() -> Self {
        Self {
            client_options: ClientOptions::default(),
            version: String::from("2026-04-06"),
        }
    }
}
```</body></comment_new>
</comments>

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

Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Copy link
Member

@tadelesh tadelesh left a comment

Choose a reason for hiding this comment

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

@copilot Use pnpm -w format to format the code and use pnpm -w change add to add changeset.

Copilot AI and others added 2 commits February 2, 2026 06:18
Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/Azure/typespec-azure/@azure-tools/typespec-client-generator-core@3877

commit: 6c81af8

Copilot AI changed the title [WIP] Add None to InitializedBy enum for client constructors Add InitializedBy.none to support omitting generated client constructors Feb 2, 2026
Copilot AI requested a review from tadelesh February 2, 2026 06:23
@tadelesh tadelesh marked this pull request as ready for review February 2, 2026 06:28
Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot Use pnpm -w format to format the code and use pnpm -w change add to add changeset.

Done! Code formatted and changeset regenerated. See commit 0e726db.

@tadelesh tadelesh changed the title Add InitializedBy.none to support omitting generated client constructors [TCGC] Add InitializedBy.none to support omitting generated client constructors Feb 2, 2026
@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Feb 2, 2026
@azure-sdk
Copy link
Collaborator

All changed packages have been documented.

  • @azure-tools/typespec-client-generator-core
Show changes

@azure-tools/typespec-client-generator-core - feature ✏️

Added InitializedBy.none (value 0) to allow TypeSpec authors to indicate that client constructors should be omitted and hand-written. Note: The internal InitializedByFlags.Default value changed from 0 to -1 to accommodate this addition.

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website

@iscai-msft iscai-msft added this pull request to the merge queue Feb 2, 2026
Merged via the queue into main with commit 08e82bb Feb 2, 2026
23 checks passed
@iscai-msft iscai-msft deleted the copilot/add-none-to-initializedby-enum branch February 2, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tcgc: add None to InitializedBy enum

4 participants