Aliases name a type; destructuring exposes components
A type alias creates another name for an existing type, not a distinct runtime or compile-time identity. Destructuring reads componentN operations, which data classes generate from constructor properties.
typealias TopicId = String
data class Topic(val id: TopicId, val title: String)
fun main() {
val topic = Topic("k1", "Kotlin")
val (id, title) = topic
check(id == "k1")
check(title == "Kotlin")
}
A plain string can still be passed where TopicId is expected. Use a wrapper or value class when confusing two identifiers should be a type error. Destructuring is positional, so changing constructor-property order can change the meaning of existing destructuring code.
Exercise
Create aliases for learner IDs and course IDs and demonstrate that the compiler still allows mixing them. Replace them with distinct data classes and observe the rejected assignment.
Check: use named property access when several neighboring components have the same type and their positions are easy to confuse.