You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---@alias aOrB "a"|"b"
---@alias aAndBPropertyAlias {a:true, b:true}
---@alias aAndBStringAlias {["a"]:true, ["b"]:true}
---@shape aAndBShape
---@field a true
---@field b true
local b = "b" ---@type aOrB
local abPropertyAlias = --[[---@type aAndBPropertyAlias]] {}
abPropertyAlias["a"] = true
abPropertyAlias.b = true
abPropertyAlias[b] = true -- No such indexer '["a"]' found on type '{ a: true, b: true } || No such indexer '["b"]' found on type '{ a: true, b: true }'
local abStringAlias = --[[---@type aAndBStringAlias]] {}
abStringAlias["a"] = true -- No such member 'a' found on type '{ ["a"]: true, ["b"]: true }'
abStringAlias.b = true -- No such member 'b' found on type '{ ["a"]: true, ["b"]: true }'
abStringAlias[b] = true
local abShape = --[[---@type aAndBShape]] {}
abShape["a"] = true
abShape.b = true
abShape[b] = true
What happens?
When using the '{}' format with either the @param or @alias annotation it doesn't recognise the keys correctly.
Using {a:true, b:true} breaks when using another alias as key.
Using {["a"]:true, ["b"]:true} does the opposite, it breaks when not using an alias
What were you expecting to happen?
The '{}' format to work the same as a @shape does. As far as I can tell these effectively define the same type of table structure.
The text was updated successfully, but these errors were encountered:
The issue wasn't really related to aliases, but rather that "doc tables" were initially much more limited than shapes. The main issue was no generics, but I later added generic aliases so you can emulate generic doc tables.
I've now gone back and made doc tables behave more like @shape. The main difference is doc tables cannot inherit from other doc tables. They also can't represent a callable type. Aside from that, they should now be pretty comparable.
In a follow-up commit to the one referenced above, I added support for inheriting from doc table aliases, or any @alias that references a legal type.
Environment
What are the steps to reproduce this issue?
What happens?
When using the '{}' format with either the
@param
or@alias
annotation it doesn't recognise the keys correctly.Using
{a:true, b:true}
breaks when using another alias as key.Using
{["a"]:true, ["b"]:true}
does the opposite, it breaks when not using an aliasWhat were you expecting to happen?
The '{}' format to work the same as a
@shape
does. As far as I can tell these effectively define the same type of table structure.The text was updated successfully, but these errors were encountered: