Skip to content

wowlua v0.9.8

Choose a tag to compare

@github-actions github-actions released this 24 Oct 10:09
· 714 commits to main since this release

0.9.8 (2026-10-24)

New

  • Function overloads: a top-level function can declare several signatures before its implementation, as a class method can: overload function find(id: number): Item?, overload function find(name: string): Item?, then function find(key: number | string): Item?. Callers see only the overloads; export overload function exports them. A signature with no implementation right after it is E3047.
  • A script handler set on an instance of your widget class gets that class: in toggle:SetScript("OnClick", function(self) … end) with class Toggle extends Button, self is a Toggle, so its fields are typed (it was a Button). The same goes for every method of the game's classes that takes or gives Self.
  • keyof T and T[K] types, as in TypeScript: function get<K extends keyof Defaults>(key: K): Defaults[K] gives each setting its own type, and a key that isn't a field of Defaults is an error (E2014).
  • SetScript and HookScript know what the game passes each script: in frame:SetScript("OnUpdate", function(self, elapsed) … end), self is the frame and elapsed a number, for every script with known arguments (OnClick, OnEnter, OnValueChanged, OnKeyDown, …).
  • W2063 reports values that are any without anyone writing it: a parameter nothing gives a type, or a local whose value is any. It is off unless you turn it on ("check": { "lints": { "W2063": "warn" } }), for projects that want any only where it is written. It also reports a generic type written without its type arguments (Box for Box<T>), which makes them any. And a field or method your widget class (class Toggle extends Button) doesn't declare: the game's frames take any field, so it passed as any.
  • EventArgs<E> works in your own functions, not only in wowlua:events: function on<E extends EventName>(event: E, fn: (name: E, EventArgs<E>...) -> ()) gives on("UNIT_HEALTH", function(name, unit) … end) the event's argument types, and function send<M extends MessageName>(name: M, ...: EventArgs<M>...) checks the values sent against declare message. Before, it was any.
  • A widget class can extend FontString, Texture, Line or MaskTexture: build it on the region its frame makes with MyLabel.adopt(frame:CreateFontString(), …).
  • MyButton.adopt(frame, …) builds a widget class on a frame that already exists, such as the buttons a secure group header makes, instead of creating a new one: your constructor runs on that frame and your @script handlers are set.
  • @deferred on an interface method's callback parameter (function on(name: string, @deferred fn: Handler)) tells the load-order check that every implementation calls it later, so a callback registered through that interface at load time no longer makes files depend on each other.
  • wowlua:reflect is typed as documented: reflect.isInstance(v, Dog) narrows v to Dog, reflect.classOf(dog) gives ClassOf<Dog>?, and reflect.enumFrom(Direction, raw) gives Direction? (reflect.enumEntries gives the members as Direction). Before, they were any and boolean. Your own generic functions can do the same: a parameter ClassOf<T> now takes T from the class or enum passed.
  • Parameter properties: a constructor's parameter can declare a field, as in TypeScript: constructor(private sink: Sink = printer, public readonly name: string) makes self.sink and self.name and sets them from the arguments. A field declared twice is now an error (E3046).
  • The standard library reads what the game gives without trusting its type: secret.asString, asNumber and asBoolean read a value typed unknown; errors.try(fn, ...) and errors.tryMethod(obj, name, ...) call a game function a client may lack, quietly; table.field(t, "a", "b") reads through values that may not be tables; table.weakKeys() and weakValues() make typed weak tables; frames.find(name) and frames.asButton(v) (and the other widget kinds) find the game's frames; frames.keepAway(frame) keeps one out of sight while it stays shown. format.money(c, { short = true }) gives "12g 5s 3c", and mock.partial({ … }) makes a typed fake record for a stub.
  • errors.tryValue(fn, ...) calls a game function a client may lack, quietly, as errors.try does, and keeps its result type: errors.tryValue(C_TradeSkillUI.GetRecipeInfo, id) is a TradeSkillRecipeInfo?, and its arguments are checked. secret.isNumber(v) and secret.isString(v) narrow a value to a number or string that isn't secret.
  • table.list(v) walks a list the game gives as unknown without a cast (for _, x in ipairs(table.list(v))), and format.ago(seconds) says how long ago: "5 min ago", or with { long = true } "3 days ago".
  • wowlua:chat opens the player's chat line: chat.whisper(name), chat.insertLink(link) (as a shift-click; a new line when none is open) and chat.open(text), through the game's own chat code on every client. unit.invite(name) invites a player to your group.
  • secure.overlay(button) puts a secure action button over one of your own buttons, for what only a secure click may do (a slash command, a click on one of the game's protected buttons): overlay.set("type1", "macro"), overlay.show() (or overlay.show(row) over another frame, such as the row under the mouse), overlay.hide(). It is anchored only while shown, so your window never turns protected and still opens in combat.
  • Restyling the game's frames: frames.textures(f), frames.fontStrings(f) and frames.children(f) give typed lists, frames.stateTextures(button) a button's state art, and frames.rows(list) the rows one of the game's lists shows (an object pool or a scroll box). events.onRegistry(name, fn) listens to Blizzard's EventRegistry callbacks, with error isolation and a subscription to cancel.
  • chat.whisperBnet(accountName) and unit.inviteBnet(gameAccountID) whisper and invite Battle.net friends, and chat.filter("CHAT_MSG_SYSTEM", fn) hides the chat lines fn returns true for, through the game's own filters (an error in fn is reported and the line shows; cancel the subscription to remove it).
  • frames.mapPins(WorldMapFrame, "QuestPinTemplate") lists the pins one of the game's maps shows of a template, as frames.
  • wowlua:chat finds the game's chat windows, typed: chat.windows() (the numbered ones, then the whisper windows), chat.docked() (in the dock's order), chat.window("ChatFrame3"), chat.editBox(w), chat.isTemporary(w) and chat.conversation(w) (a whisper window's chat type and player).
  • table.listAt(t, key) and table.recordAt(t, key) give the list or record at t[key], made and stored there when it is missing: table.insert(tbl.listAt(saved, "errors"), text) adds to a list kept in saved variables read as unknown, without a cast. frames.keyed(frame) gives the widgets a frame holds in its own fields, by key (frame.ScrollBox), for reading or restyling the game's frames.
  • mock.tooltipLines(tip?, right?) gives the lines a tooltip shows in a test (its left texts, or the right ones), and mock.sentAddonMessages() is typed: each message's prefix, message, chatType and target.
  • mock.textOf(label) gives the text a font string, button or edit box shows in a test, "" when it has none.
  • In tests, more of the game's widget methods do what they do in the game: frame:Raise() and frame:Lower() change the frame level, editBox:HighlightText() selects text that editBox:Insert(text) and mock.type then replace (typing used to append), font:CopyFontObject(other) copies the font, AdjustPointsOffset moves the anchors, and ClearModel, ClearNormalTexture, ClearText, ClearParentKey, ResetTexCoord and StopAnimating undo what was set. SetMerchantFilter, SetGuildRosterSelection and TaxiRequestEarlyLanding work too instead of failing as not mocked.
  • Tests can target as the player does: a keybinding or secure button calling TargetNearestEnemy, TargetNearestFriend and the other tab-targeting functions cycles the units in range, nearest first; TargetLastTarget, AssistUnit, FocusUnit, CancelUnitBuff and CancelSpellByName work too. An edit box keeps the lines AddHistoryLine adds, and mock.pressKey("UP") brings them back; the arrow keys run OnArrowPressed and move the cursor.
  • No game function fails as "not mocked" in tests anymore: auto attack (StartAttack, StopAttack), SetPartyAssignment, SendSystemMessage, money on the cursor (PickupPlayerMoney, GetCursorMoney), TargetLastEnemy, Sign and the rest have behaviour, and what the test client doesn't draw or keep (models' cameras, the browser, housing, movies) answers the game's empty values. ClearAttributes, ClearScripts, RemoveAnimations and LockHighlight work as in the game.

Changed

  • The game's API is typed throughout: the about 3,000 functions per game version that were any (Blizzard's UI functions such as StaticPopup_Show and CreateDataProvider, legacy C functions such as C_Garrison.GetFollowers and C_PetJournal.GetPetInfoByIndex, mixin methods) now have their parameters and results, from warcraft.wiki.gg's API pages and from Blizzard's own UI code; globals such as NUM_BAG_SLOTS and ACHIEVEMENT_YELLOW_BORDER_COLOR have their types. What no source tells is unknown instead of any: you can pass it anything, and check what it gives you before using it. A mistake in a call to one of them is now an error where it passed before.
  • A class's overload function signatures are what callers see now (they saw the implementation), and the implementation must accept each one (E3044), as documented.
  • More of the game's API is typed as the game answers: GetAchievementInfo(categoryID, index) gives the achievement's values (it gave none), its month, day and year can be nil, GetChatWindowMessages gives every message group, and fontString:GetText() and a button's GetText() are string?, because a fresh one has no text. Code that used their result as a string now has to handle nil.
  • CreateFrame("Browser") gives a Browser (and "Checkout" a Checkout) on the game versions that have them; it gave a plain Frame. frames.asBrowser(v) reads one of the game's browsers (HelpBrowser) as a Browser.
  • More game functions that were untyped have their types: Clamp, Round, Lerp, CountTable, UnitAura, UnitBuff, FindBaseSpellByID, CombatLogGetCurrentEventInfo and others, from warcraft.wiki.gg or from how another game version declares them.
  • The game's own functions that nothing documents are typed from what the game itself answered when probed (HasInboxItem(messageIndex, attachIndex), GetPlayerTradeCurrency() two numbers), or by their names (IsChatAFK() a boolean, GetNumFlyouts() a number); CombatLogGetCurrentEventInfo() gives the combat log's eleven base values typed.
  • UnitAura, UnitBuff and UnitDebuff give their values typed (name, icon, count, …), and Blizzard's utility tables have all their functions: AuraUtil.UnpackAuraData, AuraUtil.ForEachAura and the others where only some were declared.
  • hook, hookScript and the test decorators (@test, @skip, @only, @flavors, @cases, @expectError, @beforeEach, …) are typed instead of any: hook(name, fn) and hook(target, name, fn, opts?) take the function, @hook(name) gives the decorator, and a mistake in their arguments is an error. jobs.start's function may return anything, and a function wrapped with @outOfCombat returns nothing (its call may wait for combat to end).
  • The standard library takes and gives any in fewer places: mock.click, script, hover, typeText, drag, slide, dragTo, sizeBy, wheel and protect take frames (a nil frame fails the test with "mock.click: no frame"), mock.frames() gives ScriptRegion[] and mock.defineTemplate's function gets a Frame; serialize.decode and importString, reflect.getClass, superclass and classes give unknown (check it before you use it); debug.measure, errors.callIn and errors.callOwned keep the function's argument and result types, and debug.stats() its entries' fields; values only passed on (log.info(...), events.send, errors.report, table.equal, mock.fireEvent, an owner, …) are unknown.
  • An addon that lists another addon of its workspace in addon-dependencies sees that addon's @global API with all its types, as that addon has them (a value without an annotation, a class or an enum was any): wowlua check reads the other addon's sources with yours, without building them into yours or reporting their problems. You can import its types (import type UnitFrame from "suuui/UI/UnitFrame"); importing a value from it is E1041, as its modules aren't part of your addon.
  • A global made with @global has its value's type where your other files read it (it was any).
  • A value typed unknown stays unknown inside once you check its kind: after type(v) == "table", v.name is unknown (read it with secret.asString or check its type), and after type(f) == "function", f(...) gives unknown. Before, both gave any, so a mistake there went unnoticed. local ok, err = pcall(f) with an f that returns nothing gives err as unknown too.
  • Font strings in tests break text into lines as the game does (measured in the game): also after a hyphen, a word too wide for the line cut between characters, GetNumLines() counting every line (also with word wrap off or beyond SetMaxLines), and text held to fewer lines ending in an ellipsis, with GetStringWidth() the width of what shows. IsTruncated() answers. Kerning is known at more sizes.
  • local o = opts or {} keeps the type of opts (an Options? gives an Options), as do list or {} and x ?? {}: the empty table no longer turns its fields into any.
  • A class's fields and methods typed with a typeof alias (type Api = { UnitClass: typeof(UnitClass) }, api: Api) have its type inside the class's methods, where they were any.
  • select(n, …) with a number written as the index gives the types of the values from that one on: select(2, f()) is f's second result, where it was any.
  • A generic function's result type comes from a function you pass it when nothing else gives it: local ok, name = pcall(function() return unit.name end) types name, where it was any.
  • group:CreateAnimation("Alpha") gives an Alpha (and each other animation type its own), so its methods are checked; it was untyped.
  • Reading a record with a key typed keyof it (colors[k] with k: keyof Colors) gives that field's type, where it was any.
  • In a generic function or class, a value whose type is a type parameter with a constraint has the constraint's fields and methods: with B extends Frame, b:GetWidth() is a number, where it was any.
  • A generic function keeps the type of a value you pass it when that value already has one: assert(tokens[k]) with tokens: { [string]: Token } is a Token, not a string. A literal written as the argument still widens (id("x") is a string).
  • A value typed as two shapes at once, such as number[] & { hex: string }, reads c.hex as a string and c[1] as a number, where both were any.
  • local p = cache[key]; if not p then p = { seen = {} } end gives p.seen the type of the cache's seen field, where the empty table made it any.
  • Calling a method a record type doesn't declare, on a record with an indexer (m:Setting("x") with { Get: …, [string]: unknown }), calls the indexer's value: an unknown there is an error until it is narrowed (E2004), where the call was any.
  • A function passed where a function with ... parameters is expected types its parameters from them: in text:gsub("(%w+)=(%w+)", function(key, value) … end), key and value are strings, where they were any.
  • W2063 (when turned on) also reports a field one of the game's frames doesn't declare, read or called (button.owner, tooltip:AppendInfo()): it is any. Give the value a type that has it (Button & { owner: Frame? }), or read it with frames.keyed or table.field.
  • A script handler set on a frame typed with fields of your own (local b = CreateFrame("Button") :: Button & { owner: Frame? }) gets that type as self: self.owner is typed in b:SetScript("OnClick", function(self) … end), where it was any.
  • pcall(CreateFrame, "ModelScene", nil, parent) types the frame (the overload the arguments match), select(i, ...) with a variable i keeps the values' type, and reflect.isInstance(SuuUI.GetModule("x"), MyModule) narrows to MyModule though the module's declared type is unrelated; all three were any or unusable.
  • local p = x :: FramePoint keeps FramePoint (and local v = t?.field the field's type), where the local widened it to string.
  • A value typed unknown is false or nil where it is falsy: x and true or false is a boolean, and if not x then knows x is false or nil.
  • The game's transmog info (ItemTransmogInfo, as C_TransmogCollection.GetCustomSetItemTransmogInfoList gives it) has its appearanceID, secondaryAppearanceID and illusionID.
  • typeof(x) in a function's parameters and results has x's type: local function hex(k: keyof typeof(colors)) takes only the colours' names and colors[k] is typed, where both were any.
  • local w = cache[key]; if w == nil then w = false end keeps w as the cache's T | false, where false became boolean and cache[key] = w was an error.
  • A record type that refers to itself (type Entry = { name: string, members: Entry[] }) types what it holds: entry.members[1].name is a string, where it was any.
  • A type parameter with a constraint keeps a literal argument: function f<K extends "a" | "b">(k: K): K gives "a" for f("a"), where it gave string and reported that string doesn't satisfy the constraint.
  • An error naming a very long union (such as EventName) shows its first members and how many more there are, instead of all of them.
  • A function in a table you pass to a generic function gets its parameter types from the rest of the table: in segmented({ options = { { value = 5, label = "5" } }, onChange = function(v) … end }), v is the options' value type. Before, v needed an annotation (E2050). And print(f(x)) no longer turns the result of a generic f into any.
  • A local without an annotation that a loop assigns keeps its type in the loop and after it, where it was any: local found = nil set to an index in a search loop is a number? after the loop. Code that used such a local as if the loop had always set it now gets an error there (check it, or use assert).
  • A function you write in hook(…) or hookScript(…) gets the types of what it hooks: in hook(GameTooltip, "SetUnit", function(tip, unit) … end), tip is the tooltip and unit a string, and hookScript(frame, "OnSizeChanged", function(self, w, h) … end) types w and h. They were any.
  • import internal of a module's export function gives it its type, where it was any.
  • W1004 also warns about a local function with the name of another local in the same block: calls meant for the first one reach the second, also from inside it.
  • Strict mode: reading a named field of a list (list.label) or a number key a record doesn't have (art[1] of { atlas: string }) is an error (E2003); both read as any before. A list with named entries needs its type written: { [number]: string, label?: string }. Reading a table that has no indexer with a key (t[k]) is still any, and W2063 now reports it.
  • A local without a type annotation that a function changes keeps a type inside functions: local count = 0 read in a callback that does count = count + 1 is a number, a forward-declared local update is the function assigned to it later, and a flag saved and restored is a boolean. Before, they were any there, so mistakes with them went unreported; now they are checked, and W2063 no longer reports them.
  • In a class's method or constructor, a function whose parameter is named self (frame:SetScript("OnEnter", function(self) … end)) now warns (W1004): inside it, self is the frame, not your instance, and self.field reads the wrong table. Name the parameter differently. Plain function M:m() code is unchanged.
  • assert returns every argument it was given, as Lua's does, so return assert(x, "message") in a function that returns one value is now reported (too many values returned): it also handed the message to the caller, as a second value. Write return (assert(x, "message")).
  • A parameter's default can't read that parameter or a later one: in the Lua it compiles to, every parameter is in scope there and not set yet, so function f(conf: Conf = conf) or constructor(private settings: Store = settings.store) read nil, not the outer value wowlua checked them against. That is now an error (E1004); give the parameter another name. A function in a default may still use any parameter.
  • The load-order check follows MyClass.new(…): what the constructor (its default arguments included) and the field initializers read while a file loads now orders the files. Before, a default instance built at load could run before the module it reads, inside an import cycle, and fail in game with no warning.
  • The load-order check follows your classes: a method called on self, or on an instance you made with MyClass.new(…) in the same file, is that class's method (or a subclass's override), so callbacks passed through your own classes no longer count as called at load. Before, such calls were unknown and could report a dependency cycle (E1014) or W1034 that wasn't real.
  • When a generic call's result doesn't fit where it goes, the error names the call's type alone: local b: boolean = id(5) reports number?, not nil | boolean | number.
  • A readonly field can only be assigned in its initializer or in its own class's constructor, as documented: assigning it in a method, or in a subclass's constructor, is now an error (E2010).
  • A method replaced on a widget class after it is defined (MyButton.refresh = newRefresh, as a plugin might) now reaches the frames the class builds afterwards, its subclasses' too, as a plain class's instances see it. Frames built before keep the method they were given.

Fixed

  • A value written with :: keeps its type in a table: { corner = "TOPLEFT" :: FramePoint } has a FramePoint field, where it was a string.
  • frames.children, frames.textures and frames.fontStrings work on a frame with many children or regions, such as UIParent; they crashed the game there.
  • if b.owner then b.owner:Hide() end narrows b.owner when b is typed as two parts (Button & { owner: Frame? }), as it does for a record; it stayed Frame?.
  • A type predicate narrows one of the game's frames to its type: after if canDisable(f) then with canDisable(f: Frame): f is Frame & Disableable, f:SetDisabled(true) is checked; it was any.
  • Browser and OffScreenFrame frames have a frame's methods (SetPoint, SetScript, …); they had only their own.
  • A class field typed by another file's alias that uses typeof (api: UnitApi, with UnitApi = { UnitHealth: typeof(UnitHealth), … } in another file) is typed in the class's methods; it was any there.
  • A function taking an EventName (or another type of many names) no longer stops the development build from loading ("chunk has too many syntax levels"): its argument check is now a single lookup.
  • A value of several types at once fits a type of some of them: A & B & C is an A & B, where only a single A was accepted. The game's chat windows (ChatFrame1) now fit ScrollingMessageFrameMixin & Frame.
  • CreateFrame("ScrollingMessageFrame") gives a message frame: AddMessage, SetFading, ScrollToBottom, GetScrollOffset and the rest are typed, and so are the same methods of the game's chat windows (ChatFrame1:GetNumMessages() is a number). It was a plain Frame without them, and the chat windows' methods took and gave any.
  • ItemLocation:CreateFromBagAndSlot(bag, slot) gives an item location the game's functions take (C_AuctionHouse.IsSellItemValid, C_Item.GetItemName, …); it was a type of its own that none of them took.
  • date("*t") gives the time's parts (year, month, day, hour, min, sec, wday, yday, isdst) and date("%H:%M") a string; both were any.
  • W2062 warns about local x, y = pos and pos:GetXY(): an and or or keeps only one of the call's values, so y is always nil.
  • In strict mode, a name the string library doesn't have (s.message, s:nope()) is an error (E2003); it read as any. So is a named entry in a table literal where a list is expected ({ class = "X", "Y" } for a string[]), which was dropped without a word.
  • A class field typed with typeof(…) (map: typeof(WorldMapFrame)? = nil) has that type; it read as any.
  • In tests, GetItemInfo gives an item defined with mock.defineItem its link (it gave none, so item.get found nothing for it).
  • wowlua fix crashed before doing anything. It works again; migrating wowlua.json to the current schema is now wowlua fix --migrate, since --manifest <path> names the manifest for every command.
  • A class extending a class you imported with import type (class Slot extends ItemSlot) is now an error (E3008): it checked clean and failed when the addon loaded. Import the class itself (import ItemSlot from …).
  • C_DurationUtil.CreateDurationTextBinding() gives a typed binding (DurationTextBindingObject: SetDuration, SetEnabled, SetFormatter, …), where it was any, and the rule and abbreviated number formatters (C_StringUtil.CreateNumericRuleFormatter(), CreateAbbreviatedNumberFormatter()) are NumericFormatters, so they can be passed as an aura button's text formatter or a binding's.
  • The development build's argument check of a game object type (DurationObject, a colour) now takes the engine's objects: they are userdata, which it refused ("DurationObject? expected, got userdata").
  • Using self in the arguments of super(…), also inside a function written there, is now reported (E3001): such a function may run before self is your new instance (a widget class's frame doesn't exist yet), so it read the wrong table.
  • fontString:SetFormattedText(format, ...) accepts secret values among its arguments, as the game does (a target's name in a dungeon).
  • A field added to a table inside another (API.UI.Button = button after API.UI = { … }) is now part of the table other files import: they read it typed, where they got any, and a misspelled field there is an error.
  • for k, v in pairs(t) over a record type with an unknown indexer ({ name?: string, [string]: unknown }) is no longer refused (E2001).
  • Strict mode: a field your constructor sets in every branch of an if … else … end counts as set (E2052 said it wasn't), as does one set in a do block.
  • Strict mode: after self.icon = parent:CreateTexture(), calling a method on the field (self.icon:SetTexture(…)) no longer makes the next line's self.icon "may be nil" again. A call that gets a field's table can't replace the field; only calls that get the table holding it forget what you set.
  • A WoW function with several forms (SetTexCoord) accepts a last argument that gives several values, as Lua passes them: tex:SetTexCoord(unpack(coords)) was refused (E2012).
  • Texture:GetTexture() can give a number, the file ID of a texture set by one, as in the game; it was typed as a path only.
  • A cast of an optional value to a supertype of what it holds (w.tabs :: Button[] for a TabButton[]?) is no longer refused (E2015): a cast now also compares the value's type with its nil left out.
  • E2052 (a field not assigned in the constructor) says so when the field is assigned, but only after a call of one of the class's own methods on self, and names that call; before, it said the field was not assigned at all.