diff --git a/website/src/content/docs/docs/howtos/Generate client libraries/08types.mdx b/website/src/content/docs/docs/howtos/Generate client libraries/08types.mdx index f62ac503c3..4aa0268f2e 100644 --- a/website/src/content/docs/docs/howtos/Generate client libraries/08types.mdx +++ b/website/src/content/docs/docs/howtos/Generate client libraries/08types.mdx @@ -2510,7 +2510,7 @@ const ( ### Encoding -We will take the `@encode` decorator into account, determining how we serialize inputted scalars to send over the wire. +We will take the `@encode` decorator into account, determining how we serialize inputted scalars to send over the wire. When `@encode` also specifies an `encodedAs` type, TCGC preserves that wire type in its SDK model so emitters can serialize non-default representations correctly. @@ -2570,6 +2570,8 @@ jsonWriter.writeStringField("prop", When you specify an encoding type, say that you want to encode an integer as a string, that will also be represented in our generated SDKs. +This same `encodedAs` handling also applies to `string`, `url`, numeric, `boolean`, and `bytes` built-ins when they are encoded as a different wire type. + diff --git a/website/src/content/docs/docs/howtos/Generate client libraries/09renaming.mdx b/website/src/content/docs/docs/howtos/Generate client libraries/09renaming.mdx index 8b28d975ca..cddb8fa793 100644 --- a/website/src/content/docs/docs/howtos/Generate client libraries/09renaming.mdx +++ b/website/src/content/docs/docs/howtos/Generate client libraries/09renaming.mdx @@ -292,6 +292,8 @@ func (client *PetStoreNamespaceClient) Read(ctx context.Context, name string, op +For the TypeScript emitter, reserved-word operations in an operation group are automatically renamed by appending the singularized group name. For example, `Conversations.delete` becomes `deleteConversation`. If you need to keep the reserved word as the generated JavaScript method name for compatibility, apply a JavaScript-scoped override such as `@@clientName(Conversations.delete, "delete", "javascript")`. + #### Renaming operation parameters Operation parameters can be renamed using the `@clientName` decorator applied from the `client.tsp` file using the `@@` augment syntax. This is useful when you want different parameter names in the generated client SDK while keeping the wire name unchanged. diff --git a/website/src/content/docs/docs/libraries/typespec-client-generator-core/guideline.md b/website/src/content/docs/docs/libraries/typespec-client-generator-core/guideline.md index 421b78639c..15a6ff7b74 100644 --- a/website/src/content/docs/docs/libraries/typespec-client-generator-core/guideline.md +++ b/website/src/content/docs/docs/libraries/typespec-client-generator-core/guideline.md @@ -186,11 +186,11 @@ For types in TypeSpec, TCGC provides several client types to represent them in a **Built-in Types:** -- [`SdkBuiltInType`](../reference/js-api/interfaces/sdkbuiltintype/) represents a [built-in TypeSpec type](https://typespec.io/docs/language-basics/built-in-types/) or a [`scalar`](https://typespec.io/docs/language-basics/scalars/) type that derives from a built-in TypeSpec type, excluding `utcDateTime`, `offsetDateTime` and `duration`. The `encode` property indicates how to encode when sending to the service. It is set when the `@encode` decorator exists, or when the context determines a specific encoding — for example, `bytes` in a `multipart/form-data` part get `encode: "bytes"` (raw binary) rather than the default `"base64"`. +- [`SdkBuiltInType`](../reference/js-api/interfaces/sdkbuiltintype/) represents a [built-in TypeSpec type](https://typespec.io/docs/language-basics/built-in-types/) or a [`scalar`](https://typespec.io/docs/language-basics/scalars/) type that derives from a built-in TypeSpec type, excluding `utcDateTime`, `offsetDateTime` and `duration`. The `encode` property indicates how to encode when sending to the service. It is set when the `@encode` decorator exists, or when the context determines a specific encoding — for example, `bytes` in a `multipart/form-data` part get `encode: "bytes"` (raw binary) rather than the default `"base64"`. When `@encode` also specifies an `encodedAs` type, TCGC records the resolved wire representation in `wireType`, including for `string`, `url`, numeric, `boolean`, and `bytes` built-ins. **Date and Time Types:** -- [`SdkDateTimeType`](../reference/js-api/type-aliases/sdkdatetimetype/) and [`SdkDurationType`](../reference/js-api/interfaces/sdkdurationtype/) are converted from TypeSpec `utcDateTime`, `offsetDateTime` and `duration` types. The datetime encoding info is in the `encode` property. +- [`SdkDateTimeType`](../reference/js-api/type-aliases/sdkdatetimetype/) and [`SdkDurationType`](../reference/js-api/interfaces/sdkdurationtype/) are converted from TypeSpec `utcDateTime`, `offsetDateTime` and `duration` types. Their encoding metadata is carried in the `encode` and `wireType` properties. **Collection Types:**