Skip to content

Enable verbatimModuleSyntax in http-client-csharp emitter - #11515

Merged
timotheeguerin merged 3 commits into
microsoft:mainfrom
timotheeguerin:type-import-emitter-csharp
Aug 1, 2026
Merged

Enable verbatimModuleSyntax in http-client-csharp emitter#11515
timotheeguerin merged 3 commits into
microsoft:mainfrom
timotheeguerin:type-import-emitter-csharp

Conversation

@timotheeguerin

Copy link
Copy Markdown
Member

Extends the ongoing verbatimModuleSyntax rollout to the standalone C# client emitter (@typespec/http-client-csharp).

verbatimModuleSyntax makes TypeScript emit imports/exports exactly as written, which keeps type-only imports from leaking into the runtime module graph. This is the same flag already enabled across most workspace packages; this PR turns it on for the C# emitter's TypeScript layer.

What changed:

  • Add "verbatimModuleSyntax": true to emitter/tsconfig.json.
  • Convert type-only imports/exports to import type / export type (oxlint autofix, plus a manual split of mixed value/type re-exports in emitter/src/index.ts).

No runtime behavior change — this is a dev-only TypeScript configuration/import-style change.

Add verbatimModuleSyntax to the emitter tsconfig and convert type-only
imports/exports to import type / export type (oxlint autofix + manual
re-export splits in index.ts).
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jul 31, 2026
@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@pkg-pr-new

pkg-pr-new Bot commented Jul 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@11515

commit: acfe60d

@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

@jorgerangel-msft jorgerangel-msft 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.

Will this require doing the same thing to our downstream emitters that depend on this one ? ie. https://github.com/Azure/azure-sdk-for-net/tree/main/eng/packages/http-client-csharp

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 extends the TypeScript verbatimModuleSyntax rollout to the standalone C# client emitter (@typespec/http-client-csharp) by enabling the compiler flag and updating the emitter/test source to use explicit import type / export type where appropriate, preventing type-only symbols from contributing to the runtime module graph.

Changes:

  • Enabled "verbatimModuleSyntax": true in packages/http-client-csharp/emitter/tsconfig.json.
  • Converted many imports across emitter/src/** and emitter/test/** to import type where symbols are used only in type positions.
  • Split mixed value/type exports in emitter/src/index.ts into export { ... } and export type { ... } to preserve correct runtime exports.

Reviewed changes

Copilot reviewed 54 out of 54 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/http-client-csharp/emitter/tsconfig.json Enables verbatimModuleSyntax for the emitter TS layer.
packages/http-client-csharp/emitter/test/Unit/validate-dotnet-sdk.test.ts Converts compiler/testing/vitest type-only imports to import type.
packages/http-client-csharp/emitter/test/Unit/utils/test-util.ts Splits value vs type imports from compiler/testing and emitter context types.
packages/http-client-csharp/emitter/test/Unit/utils.test.ts Converts CSharpEmitterContext to a type-only import.
packages/http-client-csharp/emitter/test/Unit/usage.test.ts Converts TestHost to a type-only import.
packages/http-client-csharp/emitter/test/Unit/type-converter.test.ts Converts multiple type-only imports (DecoratorInfo, TestHost, InputNamespace) to import type.
packages/http-client-csharp/emitter/test/Unit/string-format.test.ts Converts TestHost to a type-only import.
packages/http-client-csharp/emitter/test/Unit/scalar.test.ts Converts TestHost to a type-only import.
packages/http-client-csharp/emitter/test/Unit/property-type.test.ts Converts TestHost to a type-only import.
packages/http-client-csharp/emitter/test/Unit/options.test.ts Splits CSharpEmitterOptions (type) from schema (value) import; makes compiler imports type-only.
packages/http-client-csharp/emitter/test/Unit/operation-paging.test.ts Converts TestHost to a type-only import.
packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts Converts TestHost and InputEnumType to type-only imports.
packages/http-client-csharp/emitter/test/Unit/namespace-converter.test.ts Converts TestHost and InputNamespace to type-only imports.
packages/http-client-csharp/emitter/test/Unit/model-type.test.ts Converts TestHost and InputModelType to type-only imports.
packages/http-client-csharp/emitter/test/Unit/method-parameter-segments.test.ts Converts TestHost and input-* types to type-only imports.
packages/http-client-csharp/emitter/test/Unit/input-parameter.test.ts Converts the multiline input-* import block to import type.
packages/http-client-csharp/emitter/test/Unit/enum-dedup-repro.test.ts Converts TestHost to a type-only import.
packages/http-client-csharp/emitter/test/Unit/encode.test.ts Converts TestHost to a type-only import.
packages/http-client-csharp/emitter/test/Unit/emitter.test.ts Makes compiler and emitter option/model imports type-only where applicable.
packages/http-client-csharp/emitter/test/Unit/decorator-list.test.ts Converts TestHost to a type-only import.
packages/http-client-csharp/emitter/test/Unit/constant-type.test.ts Converts TestHost and input-* types to type-only imports.
packages/http-client-csharp/emitter/test/Unit/client-model-builder.test.ts Converts TestHost and InputEnumType to type-only imports.
packages/http-client-csharp/emitter/test/Unit/client-initialization.test.ts Converts TestHost and InputMethodParameter to type-only imports.
packages/http-client-csharp/emitter/test/Unit/client-converter.test.ts Converts TestHost and InputClient to type-only imports.
packages/http-client-csharp/emitter/test/Unit/auth.test.ts Converts TestHost to a type-only import.
packages/http-client-csharp/emitter/src/type/operation-response.ts Converts referenced type imports to import type.
packages/http-client-csharp/emitter/src/type/input-type.ts Converts all imports in the module header to import type where appropriate.
packages/http-client-csharp/emitter/src/type/input-service-method.ts Converts referenced type imports to import type.
packages/http-client-csharp/emitter/src/type/input-operation.ts Converts referenced type imports to import type.
packages/http-client-csharp/emitter/src/type/input-examples.ts Converts the input type import block and OperationResponse import to type-only.
packages/http-client-csharp/emitter/src/type/input-constant.ts Converts InputType import to type-only.
packages/http-client-csharp/emitter/src/type/input-auth.ts Converts auth-shape imports to type-only.
packages/http-client-csharp/emitter/src/type/http-response-header.ts Converts InputType import to type-only.
packages/http-client-csharp/emitter/src/type/code-model.ts Converts referenced type imports to import type.
packages/http-client-csharp/emitter/src/sdk-context.ts Converts all imports in the module header to type-only (context is type-driven).
packages/http-client-csharp/emitter/src/options.ts Splits value vs type imports and makes compiler types type-only.
packages/http-client-csharp/emitter/src/lib/utils.ts Splits TCGC imports into type-only vs value imports; makes compiler/emitter context type-only.
packages/http-client-csharp/emitter/src/lib/typespec-server.ts Splits compiler/http/emitter-context imports into type-only vs value imports.
packages/http-client-csharp/emitter/src/lib/type-converter.ts Splits TCGC and compiler imports into type-only vs value imports.
packages/http-client-csharp/emitter/src/lib/service-authentication.ts Converts many referenced imports (compiler/http/context/input types) to type-only.
packages/http-client-csharp/emitter/src/lib/operation-converter.ts Splits TCGC/compiler/http imports into type-only vs value imports; converts local shape imports to type-only.
packages/http-client-csharp/emitter/src/lib/namespace-converter.ts Converts compiler/context/input imports to type-only where used for typing.
packages/http-client-csharp/emitter/src/lib/logger.ts Converts compiler imports to type-only (Logger is the runtime value).
packages/http-client-csharp/emitter/src/lib/lib.ts Converts compiler diagnostic types to import type while keeping runtime helpers as value imports.
packages/http-client-csharp/emitter/src/lib/exec-utils.ts Splits compiler and child_process imports into type-only vs value imports.
packages/http-client-csharp/emitter/src/lib/example-converter.ts Converts compiler/context/input imports to type-only where used for typing.
packages/http-client-csharp/emitter/src/lib/decorators.ts Splits compiler imports into type-only vs value imports; converts local/external types to type-only.
packages/http-client-csharp/emitter/src/lib/client-model-builder.ts Converts compiler/context/model imports to type-only where used for typing.
packages/http-client-csharp/emitter/src/lib/client-converter.ts Converts compiler/context/input imports to type-only where used for typing.
packages/http-client-csharp/emitter/src/index.ts Splits mixed exports into value exports and export type to preserve runtime module shape.
packages/http-client-csharp/emitter/src/emitter.ts Splits compiler/context/model/config imports into type-only vs value imports.
packages/http-client-csharp/emitter/src/emit-generate.ts Converts Diagnostic and CSharpEmitterContext imports to type-only.
packages/http-client-csharp/emitter/src/emit-generate.browser.ts Converts CSharpEmitterContext import to type-only (browser entrypoint typing).
packages/http-client-csharp/emitter/src/code-model-writer.ts Converts CSharpEmitterContext, CodeModel, and Configuration imports to type-only.

@timotheeguerin

Copy link
Copy Markdown
Member Author

Will this require doing the same thing to our downstream emitters that depend on this one ? ie. https://github.com/Azure/azure-sdk-for-net/tree/main/eng/packages/http-client-csharp

No this will not affect anything downstream, though you might want to do it for similar reasons.

@timotheeguerin
timotheeguerin added this pull request to the merge queue Aug 1, 2026
Merged via the queue into microsoft:main with commit 961e5aa Aug 1, 2026
29 checks passed
@timotheeguerin
timotheeguerin deleted the type-import-emitter-csharp branch August 1, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants