Enable verbatimModuleSyntax in http-client-csharp emitter - #11515
Conversation
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).
|
You can try these changes here
|
commit: |
|
No changes needing a change description found. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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": trueinpackages/http-client-csharp/emitter/tsconfig.json. - Converted many imports across
emitter/src/**andemitter/test/**toimport typewhere symbols are used only in type positions. - Split mixed value/type exports in
emitter/src/index.tsintoexport { ... }andexport 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. |
No this will not affect anything downstream, though you might want to do it for similar reasons. |
Extends the ongoing
verbatimModuleSyntaxrollout to the standalone C# client emitter (@typespec/http-client-csharp).verbatimModuleSyntaxmakes 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:
"verbatimModuleSyntax": truetoemitter/tsconfig.json.import type/export type(oxlint autofix, plus a manual split of mixed value/type re-exports inemitter/src/index.ts).No runtime behavior change — this is a dev-only TypeScript configuration/import-style change.