Skip to navigation

TypeScript serde layer

View as Markdown

Fern’s TypeScript SDK generator includes an optional serde layer that determines whether the generated SDK matches your original API naming conventions (snake_case vs. camelCase, case-sensitive fields) or follows TypeScript conventions. This serde layer is controlled by the serdeLayer option in the TypeScript target’s generation block in sdk-config.yml.

By default, the serde layer is disabled, meaning field names are preserved exactly as they appear in your API specification.

When to enable the serde layer

sdk-config.yml
targets:
- language: typescript
generation:
serdeLayer: true # Enable serde layer

When you turn on the serde layer (serdeLayer: true), the TypeScript SDK generator includes custom serialization code that:

  • Transforms all property names from your API to camelCase
  • Validates requests and responses at runtime
  • Supports complex types like Date and Set.

Enable the serde layer when you want idiomatic TypeScript conventions and don’t have case-sensitive field conflicts. Keep it disabled when your API has fields that differ only by casing or when you need exact field name preservation.

Additional configuration options

Set useBigInt: true alongside an enabled serde layer to preserve precision for large numbers. It only takes effect when the serde layer is enabled (serdeLayer: true), as it requires the custom serialization infrastructure.

sdk-config.yml doesn’t have the skipResponseValidation and allowExtraFields options yet. To use them with generators.yml, see the Legacy TypeScript serde layer page.

sdk-config.yml
targets:
- language: typescript
generation:
serdeLayer: true # Enable serde layer
useBigInt: true # Preserve precision for large numbers

For the complete list of all TypeScript configuration options, go to TypeScript configuration.