I was making a (semi-quick) module for a dialogue system for a module, and I had some types that were nested into another type.
I exported the “parent” type and tried to access it in another script, but I couldn’t see the variables of the nested types when checking the code. I’m wondering: Do I need to export the types that are included in another type, or do the types get carried over?
Code (only section that matters basically):
local guiFunctions = require(script.Parent.GuiFunctionsModule)
local dialogue = {}
dialogue.__index = dialogue
setmetatable(dialogue, guiFunctions)
type ValueForDisplay = {
Value: Instance,
NeededValue: any
}
type ValueToChange = {
Value: Instance,
ValueToChange: any
}
type Question = {
Texts: {string},
ValueForDisplay: ValueForDisplay,
ValueToChange: ValueToChange,
NextPosition: "number | Can be a string to go to specific name"
}
export type DialogueChunk = typeof(setmetatable({} :: {
Name: string,
Position: "number | The position of the dialogue chunk in the conversation, multiple can be in the same place, -1 to force end",
Texts: {string}?,
Characters: {string}?, --Unused for now, will be useful for having multi character conversations
Type: "string | default Text | Text, Question |",
Answers: {Question},
ValueForDisplay: ValueForDisplay,
NextPosition: "number | Can be a string to go to specific name"
}, dialogue))
And here’s an image of the problem:
Notice how question is shown here...
But the variables of question are not shown here
I haven’t seen anyone really use nested types (and firstly I’m a little worried I’m doing something unconventional; I’ll probably post my full code in code feedback to see if it’s alright) so I decided to ask this real quick while I’m still working on the code. Also (side question) is it ok to use types like this? I’m not sure if they’re un-performant if used en masse. Thanks!