diff --git a/.luarc.json b/.luarc.json index 4e16790..f459b7c 100644 --- a/.luarc.json +++ b/.luarc.json @@ -5,7 +5,7 @@ }, "workspace": { "library": [ - "./src/runtime" + "src/lua/runtime" ], "checkThirdParty": "Disable" }, diff --git a/src/lua/runtime/h.lua b/src/lua/runtime/h.lua index ed1acff..8e48b15 100644 --- a/src/lua/runtime/h.lua +++ b/src/lua/runtime/h.lua @@ -1,5 +1,6 @@ ---@class H ----@operator call: fun(v: Displayable): string +---@overload fun(tag: string, children: Displayable|Children): Element +---@overload fun(children: Displayable|Children): Element local h = {} h.document = maivi.elem("!DOCTYPE html", { close = false }) diff --git a/src/lua/runtime/maivi.lua b/src/lua/runtime/maivi.lua index f179d54..16f8e7d 100644 --- a/src/lua/runtime/maivi.lua +++ b/src/lua/runtime/maivi.lua @@ -52,7 +52,7 @@ end ---@alias PropsOrChildren { [string]: Displayable, [integer]: Displayable } ---| Displayable ----@alias VNode { type: ElementType, props: PropsOrChildren } +---@alias VNode { type: ElementType, props: Props, children: Children } ---@alias ElementType string | Component ---@alias Element VNode | Component ---@alias Component fun(props: Props, children: ComponentChild[]): Element @@ -70,6 +70,7 @@ end ---@param etype ElementType? ---@param props Props ---@param children ComponentChild[] +---@return Element function maivi.h(etype, props, children) if type(etype) == "function" then return etype(props, children) @@ -79,6 +80,7 @@ end ---@param etype ElementType ---@param config? ElementConfig +---@return Element function maivi.elem(etype, config) return function(args) local parsed = maivi.parse(args)