Autocomplete breaks for nested tables when using type intersections

Roblox / luau will fail to provide autocomplete when using the following patterns:
image

Removing the type intersection from Car fixes the issue.

System Specs:

  • Ryzen 9 9800X3D
  • RTX 3080
  • Windows 10

Beta Features:



Raw code for repo:

type GenericDatabase<T> = {
	Items: {T},
}

type GenericItem = {
	ItemID: string,
}

type CarUpgrade = {
	Price: number,
}

type Car = {
	Upgrades: {CarUpgrade}
} & GenericItem -- Comment out this type intersection to fix autocomplete.


local Database: GenericDatabase<Car> = {}

Database.Items = {
	{
		Upgrades = {
			{
				pri -- This will not auto complete "Price"
			}
		}
	}
}

Expected behavior

I expect the Upgrade type to have autofill.

Upgrades is defined as an array of dictionaries. In your example, you are accidentally using it as just a dictionary itself, which is possibly the reason for you not getting auto-complete. The following should ideally get you autocomplete:

type Upgrade = {
	Price: number,
}

type Item = {
	Upgrades: {Upgrade}
}

type ThingDatabase = {
	Items: {Item}
}

local Database: ThingDatabase = {}

Database.Items = {
	{
		Upgrades = {
			{
				Pr
			} -- Each upgrade needs to be its own dictionary, even if we only have one
		}
	}
}

Alternatively, if you want to support Upgrades being a dictionary itself when you only have one upgrade. From a typechecking perspective, you could define the Item type as:

type Item = {
	Upgrades: {Upgrade}|Upgrade
}

Yeah this was a mistake in my original post, this fixed my issue in my example code but I’m still getting the issue in a different script. The issue I’m experiencing is actually related to type intersections. I’m currently in the process of updating my original post to reflect the actual issue.

This snippet results in proper autocomplete for Upgrades:
image

This one does not: (only difference is the lack of & StoreItem)
image

Here are the types I’m intersecting with, removing the intersection between StoreItem and GenericItem doesn’t fix anything either.
image

This is just an acknowledgment announcement!

We’ve filed a ticket to our internal database, and we’ll follow up when we have an update!

Thanks for the report!