Skip to content

Feature Request/How-to: Inlined parameter annotationΒ #2250

@BribeFromTheHive

Description

@BribeFromTheHive

I'd like to be able to do inlined type annotation for parameters. It doesn't currently seem to be possible. What I mean is, instead of this:

---@param key                       unknown
---@param callbackFn                fun(Hook, ...):any
---@param priority?                 number
---@param hostTableToHook?          table
---@param defaultNativeBehavior?    function
---@param hookedTableIsMetaTable?   boolean
function Hook.basic(key, callbackFn, priority, hostTableToHook, defaultNativeBehavior, hookedTableIsMetaTable)
    return Hook.add(key, callbackFn, priority, hostTableToHook, defaultNativeBehavior, hookedTableIsMetaTable, true)
end

I'd like to be able to do this:

function Hook.basic(
    key,                    ---@param unknown
    callbackFn,             ---@param fun(Hook, ...):any
    priority,               ---@param? number
    hostTableToHook,        ---@param? table
    defaultNativeBehavior,  ---@param? function
    hookedTableIsMetaTable  ---@param? boolean
)
    return Hook.add(key, callbackFn, priority, hostTableToHook, defaultNativeBehavior, hookedTableIsMetaTable, true)
end

This would cut down on the boilerplate a bit and make the code cleaner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions