Structural SubtypingΒΆ

A structural type A is said to be a structural subtype of another type B when A declares all of the members of B.

Note

It does not matter whether A declares more members than B; as long as A declares at least all of the members of B, then A is a subtype of B.

For instance, in this snippet:

a = {
    x = 'former'
    y = 'latter'
}

b: [x: ''] = a

the type of a is a structural subtype of [x: ''] (the type of b), because a defines at least a member x: ''. This is why assigning a to b is perfectly legal.