Autocomplete doesn't work with this type pattern. (Possible nesting issue)

Roblox / luau will fail to provide autocomplete when using the following type pattern (persumably has the same issue for any similar nesting):
image

System Specs:

  • Ryzen 9 9800X3D
  • RTX 3080
  • Windows 10

Beta Features:



Raw code for repo:

type Upgrade = {
	Price: number,
}

type Item = {
	Upgrades: {Upgrade}
}

type ThingDatabase = {
	Items: {Item}
}

local Database: ThingDatabase = {}

Database.Items = {
	{
		Upgrades = {
			pr
		}
	}
}

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
}