Intellisense: How to get exported Type to Show in Intellisense?

As per Luau’s documentation (bottom of Syntax - Luau (luau-lang.org)), I am exporting a custom Type definition in a ModuleScript. Shown below

local InventoryItem = {}
-- some other code

export type InventoryItemType = {id: string, count: number, isStackable: boolean, displayName: string, itemType: string, localUIFrame: Frame?}

return InventoryItem

In my other module, I am requiring that InventoryItem module like so

However, my Intellisense is not recognizing the type and giving me autocompletions or type hints for it.

image

It only does so if I use it in the same ModuleScript I defined the type in (shown below)

image

How can I make the Roblox script editor’s intellisense autocomplete the exported custom type?

The problem is that you’re not saving the type corrently as you’re trying to save it as a local variable instead of a type. You can fix this easily:

local InventoryItemType = require(gameClasses:WaitForChild("InventoryItem"))
type InventoryItemType = InventoryItemType.InventoryItemType

local ShopUI = {}
ShopUI.__index = ShopUI

function ShopUI:addItem(inventoryItem: InventoryItemType)
	inventoryItem. --It should show the keys of the "inventoryItem" table.
end

1 Like

Your help is appreciated - thank you. That does work.