The following code should have no type errors because in both union options we have the same fields. However, the type checker doesn’t like it, and for both lines gives the error Expected type table, got 'A1 | A2' instead
type A1 = {
B: number?;
C: number;
}
type A2 = {
B: number?;
C: number;
}
type A = A1 | A2
local A: A = nil
if not A.B then
-- These two lines have type errors.
A.B = 1
A.C = 2
end