issue with HeadingLevel
im currently building a function called createTitleBodyResponse which takes in 4 parameters, one of them being a title_size which corresponds to a HeadingLevel. for some reason, there is an error when i attempt to use this logic. the first implementation has the error
while the error on the second implementation is


16 Replies
does anybody know how i can fix this? im not even sure if im doing something wrong or if its something to do with the typings
I think this is a bug. seems like the underling functions is not being exported correctly
heading(content: string, level?: HeadingLevel)
You can Ignore the error by using //@ts-expect-error
I was able to replicate the error with the following code
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
return typing of
# {string}
vs ## {string}
vs ### {string}
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
so is this just a typings issue?
Yes, best work around is
//@ts-expect-error
The underlying function should still workwith either implementation?
Yeah, you place it on the line before you call the heading function and it tells the typescript compiler to ignore the error. That should work
so whats the proper way then
well from what people are saying its a typings issue
so i should use one of those comments for now and wait for it to be fixed? i dont think id know how to fix this myself (as in make a pr)
ah i see
so then when ts complains, ill know its fixed and i can remove the comment
ok that makes sense thank you for the help
Have you tried using your own formatter function? title_size is undefined or not imported properly
You could do something like:
And then use:
the issue is about the djs function though
Typescripts function overload resolution doesnt work well with unions to my knowledge.
He could solve this by using a switch or if statement to narrow the title size before calling heading()
I dont think the problem is within js
That would at least solve the overload issues in his console output
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
Basically.
But thankfully there are workarounds
Try one of the solutions i put above