luau
luau copied to clipboard
Type solver randomly fails for no reason
Code:
local blockNodes: {markdown.MarkdownNode} = {}
-- Add header node
blockNodes[#blockNodes + 1] = {
type = "Heading",
level = depth,
headingText = markdown.NewMarkdownText_FromRaw(typ.field_name)
}
if convertedComments.output ~= "" then
-- Add converted comments output as well
blockNodes[#blockNodes + 1] = {
type = "Text",
text = markdown.NewMarkdownText_FromRaw(convertedComments.output)
}
end
local fieldtype = typ.field_type:extract()
if fieldtype.type == "Function" then
-- Insert code block of function declaration
blockNodes[#blockNodes + 1] = {
type = "CodeBlock",
description = "Function Signature",
language = "luau",
text = typ:string_repr_with_pats("\n"),
}
The above fails for no apparent reason. A workaround (right now) that does get it working is changing type = "CodeBlock" to type = "CodeBlock" :: "CodeBlock", which (for whatever reason) does make it work