When defining multiple types in an array:
export type SomeArray = { string | number }
Then using it like this:
local x: SomeArray = {
"123",
123
}
Luau type resolver always assumes the first defined child as the one, single type for the entire array.
So, here I get a type checking error that number can’t be converted to string.
If I reverse the order of children like so:
local x: SomeArray = {
123,
"123"
}
I will get a type checking error that string cannot be converted to number
The reason for this post is because I 've seen multiple threads with the same bug that have been marked as fixed, even though it is not.
What I expect to happen:
I expect the type resolver to allow both types to be in a container. If I wanted to define two array of a single type, I would define it like this:
export type SomeArray = { string } | { number }
