How to show that an instance is required to have a child of a certain type with Luau type annotations?

Hello! I am a fan of typisation with luau, however something I ran into is how to define that an instance needs to have a child of another type. For example, if I need a part that has a bodygyro under it, how do I show that with the type annotation?

This is achieved through type intersections. Think of it like “type extends X”

type Example = Instance & {
    BodyGyro: BodyGyro,
}

Above, we describe an instance which should contain an additional member called “BodyGyro” of type BodyGyro

2 Likes

Thanks, that’s what I was looking for