# RudderTyper v2


{{< announcement >}}
This feature is in **Public Beta** as part of RudderStack's Early Access Program, where we work with early users and customers to test new features and get feedback before making them generally available.
{{< /announcement >}}

RudderTyper v2 leverages the [Rudder CLI]({{< ref "dev-tools/rudder-cli/" >}}) functionality to generate type-safe client bindings from your [Tracking Plans]({{< ref "data-governance/tracking-plans/" >}}), enabling compile-time type safety and a better developer experience when instrumenting your applications. By generating native code that matches your Tracking Plan's event definitions, you can catch errors at compile time rather than runtime.

{{< info >}}
RudderTyper v2 supports generating [TypeScript bindings](https://github.com/rudderlabs/rudder-sdk-js) for the [JavaScript SDK]({{< ref "sources/event-streams/sdks/rudderstack-javascript-sdk/" >}}), [Kotlin bindings](https://github.com/rudderlabs/rudder-sdk-kotlin) for Android and JVM platforms, and [Swift bindings](https://github.com/rudderlabs/rudder-sdk-swift) for iOS.

RudderTyper v2 is the actively maintained version and will receive all future updates. For the older npm-based version that supports JavaScript, TypeScript, Java, and Objective-C, see [RudderTyper v1]({{< ref "dev-tools/ruddertyper.md" >}}).
{{< /info >}}

## Key features

This section highlights the key features of RudderTyper v2.

#### Type-safe event tracking

- Generate strongly-typed TypeScript types, Kotlin classes, and Swift structs that match your Tracking Plan's event structure
- Compile-time validation ensures your code matches your Tracking Plan definitions
- IntelliSense support for autocomplete and type checking in your IDE

#### Platform support

- **TypeScript**: Generate bindings for browser-based web applications using the [JavaScript SDK]({{< ref "sources/event-streams/sdks/rudderstack-javascript-sdk/" >}})
- **Kotlin**: Generate bindings for both Android and JVM platforms
- **Swift**: Generate bindings for iOS applications
- Support for all standard RudderStack event types: `track`, `identify`, `screen`, `page`, and `group`

#### Customizable code generation

- Configure platform-specific options like package names or output file names for generated code
- Generate code that integrates seamlessly with the [JavaScript SDK]({{< ref "sources/event-streams/sdks/rudderstack-javascript-sdk/" >}}), [Android (Kotlin) SDK]({{< ref "sources/event-streams/sdks/kotlin-sdk/" >}}), or [iOS (Swift) SDK]({{< ref "sources/event-streams/sdks/swift-sdk/" >}})

#### CLI integration

- Generate bindings directly from your Tracking Plans using [Rudder CLI]({{< ref "dev-tools/rudder-cli/" >}})
- Browse and select Tracking Plans interactively
- Simple command-line interface for code generation

## Limitations

Although the generated bindings leverage language features (TypeScript, Kotlin, and Swift) to ensure compile-time type safety and compliance with Tracking Plan rules, the following scenarios **cannot be handled** at compile time:

#### Validating property rules

Rules like regular expressions or length constraints on values cannot be enforced at compile time because the value is only available at runtime. The only exception to this is enum constraints, which are modeled as enum types (TypeScript union type aliases, Kotlin enum classes, or Swift enums with raw values), restricting which values can be assigned to respective properties.

#### Object properties with additional properties

Properties of **Object** type typically allow objects of any shape to be passed as values. RudderTyper represents this as the `Record<string, unknown>` type in TypeScript, the `JsonObject` type in Kotlin, or `[String: Any]` in Swift, which can represent any object.

If those properties are used in a Tracking Plan event rule, you can define nested properties for them to restrict the shape of the object property. In that context, you can define whether additional properties (to those mentioned as nested properties) are allowed or not.

While RudderTyper can represent object shapes that don't allow additional properties, it cannot do the same for object shapes that allow them. These are represented as if additional properties are not allowed.

## Get started

| Guide | <div style="width:350px">Description</div> |
| :---- | :---- |
| [RudderTyper v2 Walkthrough Guide]({{< ref "dev-tools/rudder-cli/ruddertyper-v2-walkthrough.md" >}}) | Step-by-step tutorial to generate and use type-safe bindings in your application |
| [RudderTyper v2 Command Reference]({{< ref "dev-tools/rudder-cli/ruddertyper-v2-command-reference.md" >}}) | Complete reference for RudderTyper v2 CLI commands and parameters |

