Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<ClientTabs>
<ClientTabItem lang="typespec" >
Expand Down Expand Up @@ -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.

<ClientTabs>
<ClientTabItem lang="typespec" >

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ func (client *PetStoreNamespaceClient) Read(ctx context.Context, name string, op

</ClientTabs>

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down