> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kotlin Type Alias

A type alias in Kotlin provides an alternative name for an existing type. It does not introduce a new type into the type system; rather, it acts as a compile-time substitution. During compilation, the Kotlin compiler replaces the alias with its underlying target type, meaning the alias and the original type are strictly identical and interchangeable in the generated bytecode.

## Syntax

Type aliases are declared using the `typealias` keyword, followed by the new identifier, an assignment operator, and the target type.

```kotlin theme={"dark"}
typealias AliasName = TargetType
```

## Technical Characteristics

* **Top-Level Declaration:** Type aliases must be declared at the top level of a file. They cannot be nested inside classes, objects, interfaces, or local scopes (functions).
* **Type Identity:** Because a type alias is not a distinct type, an instance of the alias can be assigned to a variable of the original type, and vice versa, without any type casting or conversion.
* **Visibility Modifiers:** Type aliases support standard visibility modifiers (`public`, `private`, `internal`). A type alias cannot have a more permissive visibility than its underlying target type.

## Structural Mechanics

**1. Standard Type Substitution**
A direct mapping to an existing class, interface, or parameterized type.

```kotlin theme={"dark"}
typealias StringMap = Map<String, String>

val headers: StringMap = mapOf("Accept" to "application/json")
val standardMap: Map<String, String> = headers // Strictly identical, no cast required
```

**2. Function Type Aliasing**
Type aliases can represent function signatures, including those with receivers, multiple parameters, or specific return types.

```kotlin theme={"dark"}
typealias CoordinatesHandler = (x: Int, y: Int) -> Unit
typealias Transformer<T, R> = (T) -> R
```

**3. Generic Type Parameterization**
Type aliases can declare their own generic type parameters, which are then applied to the underlying target type.

```kotlin theme={"dark"}
typealias Matrix<T> = List<List<T>>
typealias Dictionary<V> = Map<String, V>

// Instantiation applies the generic type to the underlying Map
val dict: Dictionary<Int> = mapOf("count" to 1) 
```

**4. Nested and Inner Class Aliasing**
Type aliases can resolve fully qualified paths to nested or inner classes at compile time.

```kotlin theme={"dark"}
class NetworkManager {
    inner class Connection
}

typealias NetConnection = NetworkManager.Connection
```

## Reflection and Type Checking

Because type aliases are resolved during compilation, runtime type checks (`is` operator) and reflection evaluate the underlying type, not the alias. Class literals using the alias are fully supported by the compiler and evaluate directly to the class literal of the underlying target type.

```kotlin theme={"dark"}
typealias AuthToken = String

val token: AuthToken = "abc-123"

// Evaluates to true because AuthToken is compiled as String
println(token is String) 

// Valid syntax: AuthToken::class evaluates to String::class
println(AuthToken::class == String::class) // Prints: true
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Kotlin Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
