vscode-wow-api icon indicating copy to clipboard operation
vscode-wow-api copied to clipboard

Types Missing and BackdropTemplate Type Warnings

Open markoleptic opened this issue 11 months ago • 4 comments

I believe one of the recent updates removed the backdropInfo and backdropInsets types.

Since updating to 0.19.1, I've been getting param-type-mismatch type warnings when creating frames using the "BackdropTemplate" argument. If I revert to 0.18.2, these go away.

local button = CreateFrame("Button", Type .. "Button" .. count, frame, "BackdropTemplate") button:SetBackdrop(buttonBackdrop) Cannot assign table|BackdropTemplate|Button to parameter BackdropTemplateMixin.

However, if I hover over the function definition for SetBackdrop, it correctly shows the preview: (method) BackdropTemplateMixin:SetBackdrop(backdropInfo: any)

Same thing happens if I explicitly type it: ---@type table|Button|BackdropTemplateMixin

markoleptic avatar Apr 06 '25 01:04 markoleptic

I still don't know why but it's fixed by adding local infront of the mixin. I indeed used this "hack" until I switched in v0.19.0 to the generated FrameXML annotations by @Numynum

- BackdropTemplateMixin = { }
+ local BackdropTemplateMixin = { }
  • 0.18.2 https://github.com/Ketho/vscode-wow-api/blob/0.18.2/Annotations/Widget/UIType/Template/Backdrop.lua#L19
  • 0.19.0 https://github.com/NumyAddon/FramexmlAnnotations/blob/efe381e8b372abd66c89697df97c2ca042c737be/Annotations/AddOns/Blizzard_SharedXML/Backdrop.lua.annotated.lua#L5

Since the annotations are in a submodule now I'd have to bother Numy to fix it. (But I might have to fallback to manually annotating or generating the FrameXML annotations myself)

Ketho avatar Apr 06 '25 02:04 Ketho

I can certainly take a look

Numynum avatar Apr 06 '25 04:04 Numynum

Oh, that is strange! I've never fully understood how meta files are parsed, especially templates. Just kinda did stuff until it worked..

I despise dynamically typed languages and I explicitly type everything in Lua, so I really appreciate the work put in to this project.

markoleptic avatar Apr 06 '25 04:04 markoleptic

Besides the backdrop types it's also missing param arguments and returns yes, as that's a bit more difficult to generate from the mixins instead of manually

Ketho avatar Apr 06 '25 05:04 Ketho

~~I played around a little, and I'll adjust the annotation generator~~ edit, actually I found something that might be problematic, looking a bit more

I'd recommend putting the manual annotation back in though, at least for functions that have extra information (such as param/return types)

Numynum avatar Apr 06 '25 09:04 Numynum

I don't really like the workaround of putting local in front of the mixin definition, since it causes other QoL issues (when you add framexml as a luals workspace library)

a different workaround you can consider is to use "type.weakUnionCheck": true; which I think is likely generally the desired behaviour in the context of wow addons anyway

Numynum avatar Apr 06 '25 10:04 Numynum

I've enabled the type.weakUnionCheck option which prevents the diagnostic warning.

But I will make the load FrameXML option disabled by default since it takes around 14 seconds to load them all. I can't really seem to find a good middle ground to supporting templates easily and not just loading the whole framexml folder.

~~Instead of submoduling I'm thinking of manually copying Numy's repo, and then moving some files to a different folder and making some manual changes for stuff like BackdropTemplate, ItemLocation, etc.~~

Ketho avatar Apr 10 '25 16:04 Ketho