diff options
author | Maria José Solano <majosolano99@gmail.com> | 2024-10-17 21:03:20 -0700 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-10-18 07:36:54 +0100 |
commit | 31745b17e60df8efd25bc2d76fc4bd16f9959441 (patch) | |
tree | 87b932a1c1eb14add20bb857ba92237251c312a2 | |
parent | 27f3a2002c50dbe4d0be486201bf63446cf95838 (diff) | |
download | rneovim-31745b17e60df8efd25bc2d76fc4bd16f9959441.tar.gz rneovim-31745b17e60df8efd25bc2d76fc4bd16f9959441.tar.bz2 rneovim-31745b17e60df8efd25bc2d76fc4bd16f9959441.zip |
fix(types): add narrower vim.validate types
-rw-r--r-- | runtime/lua/vim/shared.lua | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 0f636401bb..d11489b539 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -779,15 +779,17 @@ function vim.endswith(s, suffix) end do - --- @alias vim.validate.Type - --- | 't' | 'table' - --- | 's' | 'string' - --- | 'n' | 'number' - --- | 'f' | 'function' - --- | 'c' | 'callable' + --- @alias vim.validate.LuaType --- | 'nil' + --- | 'number' + --- | 'string' + --- | 'boolean' + --- | 'table' + --- | 'function' --- | 'thread' - --- | 'userdata + --- | 'userdata' + --- + --- @alias vim.validate.Type vim.validate.LuaType | 't' | 's' | 'n' | 'f' | 'c' local type_names = { ['table'] = 'table', @@ -810,7 +812,7 @@ do --- @nodoc --- @class vim.validate.Spec [any, string|string[], boolean] --- @field [1] any Argument value - --- @field [2] string|string[]|fun(v:any):boolean, string? Type name, or callable + --- @field [2] vim.validate.Type|vim.validate.Type[]|fun(v:any):boolean, string? Type name, or callable --- @field [3]? boolean local function _is_type(val, t) @@ -973,7 +975,7 @@ do --- only if the argument is valid. Can optionally return an additional --- informative error message as the second returned value. --- - msg: (optional) error string if validation fails - --- @overload fun(name: string, val: any, expected: string, optional?: boolean) + --- @overload fun(name: string, val: any, expected: vim.validate.LuaType, optional?: boolean) function vim.validate(opt, ...) local ok = false local err_msg ---@type string? |