Skip to content

[config.keys]: Cannot assign ActionClass|ActionFuncClass to .... #82

@reegnz

Description

@reegnz

Conditions

  • I have checked for existing issues related to this one, whether open or closed.
  • I have checked for existing PRs and none address this, whether open or closed.
  • I have read the WezTerm Lua Reference and can confirm this type is not deprecated.

What version of WezTerm are you using? (wezterm --version)

wezterm 20240203-110809-5046fc22

What text editor are you using?

Neovim

Operating system and, if possible, what version?

MacOS Sequoia 15.6.1

Describe The Issue

I get type assignment warnings in my wezterm config whenever I do a custom key binding.
These are not exceptional extra custom key mappings, but mappings lifted directly from the wezterm docs.

This is an example minimal config pulled from https://wezterm.org/config/lua/keyassignment/AdjustPaneSize.html but added the @type Wezterm line at the top and wezterm.config_builder() to infer the type of config. This makes type checker errors appear.
Adding ---@type Config instead of using the wezterm.config_builder() also causes the same type issues.

---@type Wezterm
local wezterm = require("wezterm")
local act = wezterm.action
local config = wezterm.config_builder()

config.leader = { key = "a", mods = "CTRL" }
config.keys = {
	{
		key = "H",
		mods = "LEADER",
		action = act.AdjustPaneSize({ "Left", 5 }),
	},
	{
		key = "J",
		mods = "LEADER",
		action = act.AdjustPaneSize({ "Down", 5 }),
	},
	{ key = "K", mods = "LEADER", action = act.AdjustPaneSize({ "Up", 5 }) },
	{
		key = "L",
		mods = "LEADER",
		action = act.AdjustPaneSize({ "Right", 5 }),
	},
}
return config
     ├╴  Cannot assign `ActionClass|ActionFuncClass` to `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`.
     │    - `ActionFuncClass` cannot match `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`
     │    - `ActionFuncClass` cannot match any subtypes in `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`
     │    - Type `ActionFuncClass` cannot match `nil`
     │    - Type `ActionFuncClass` cannot match `"TogglePaneZoomState"`
     │    - Type `ActionFuncClass` cannot match `"ToggleFullScreen"`
     │    - Type `ActionFuncClass` cannot match `"SwitchWorkspaceRelative"`
     │    - Type `ActionFuncClass` cannot match `"SwitchToWorkspace"`
     │    - Type `ActionFuncClass` cannot match `"StartWindowDrag"`
     │    - Type `ActionFuncClass` cannot match `"SplitVertical"`
     │    - Type `ActionFuncClass` cannot match `"SplitPane"`
     │    - Type `ActionFuncClass` cannot match `"SplitHorizontal"`
     │    - Type `ActionFuncClass` cannot match `"SpawnWindow"`
     │    ...(+69)
     │    - Type `ActionFuncClass` cannot match `"ActivateKeyTable"`
     │    - Type `ActionFuncClass` cannot match `"ActivateCopyMode"`
     │    - Type `ActionFuncClass` cannot match `"ActivateCommandPalette"` Lua Diagnostics. (assign-type-mismatch) [11, 3]
     ├╴  Cannot assign `ActionClass|ActionFuncClass` to `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`.
     │    - `ActionFuncClass` cannot match `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`
     │    - `ActionFuncClass` cannot match any subtypes in `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`
     │    - Type `ActionFuncClass` cannot match `nil`
     │    - Type `ActionFuncClass` cannot match `"TogglePaneZoomState"`
     │    - Type `ActionFuncClass` cannot match `"ToggleFullScreen"`
     │    - Type `ActionFuncClass` cannot match `"SwitchWorkspaceRelative"`
     │    - Type `ActionFuncClass` cannot match `"SwitchToWorkspace"`
     │    - Type `ActionFuncClass` cannot match `"StartWindowDrag"`
     │    - Type `ActionFuncClass` cannot match `"SplitVertical"`
     │    - Type `ActionFuncClass` cannot match `"SplitPane"`
     │    - Type `ActionFuncClass` cannot match `"SplitHorizontal"`
     │    - Type `ActionFuncClass` cannot match `"SpawnWindow"`
     │    ...(+69)
     │    - Type `ActionFuncClass` cannot match `"ActivateKeyTable"`
     │    - Type `ActionFuncClass` cannot match `"ActivateCopyMode"`
     │    - Type `ActionFuncClass` cannot match `"ActivateCommandPalette"` Lua Diagnostics. (assign-type-mismatch) [16, 3]
     ├╴  Cannot assign `ActionClass|ActionFuncClass` to `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`.
     │    - `ActionFuncClass` cannot match `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`
     │    - `ActionFuncClass` cannot match any subtypes in `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`
     │    - Type `ActionFuncClass` cannot match `nil`
     │    - Type `ActionFuncClass` cannot match `"TogglePaneZoomState"`
     │    - Type `ActionFuncClass` cannot match `"ToggleFullScreen"`
     │    - Type `ActionFuncClass` cannot match `"SwitchWorkspaceRelative"`
     │    - Type `ActionFuncClass` cannot match `"SwitchToWorkspace"`
     │    - Type `ActionFuncClass` cannot match `"StartWindowDrag"`
     │    - Type `ActionFuncClass` cannot match `"SplitVertical"`
     │    - Type `ActionFuncClass` cannot match `"SplitPane"`
     │    - Type `ActionFuncClass` cannot match `"SplitHorizontal"`
     │    - Type `ActionFuncClass` cannot match `"SpawnWindow"`
     │    ...(+69)
     │    - Type `ActionFuncClass` cannot match `"ActivateKeyTable"`
     │    - Type `ActionFuncClass` cannot match `"ActivateCopyMode"`
     │    - Type `ActionFuncClass` cannot match `"ActivateCommandPalette"` Lua Diagnostics. (assign-type-mismatch) [18, 32]
     └╴  Cannot assign `ActionClass|ActionFuncClass` to `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`.
          - `ActionFuncClass` cannot match `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`
          - `ActionFuncClass` cannot match any subtypes in `("ActivateCommandPalette"|"ActivateCopyMode"|"ActivateKeyTable"|"ActivateLastTab"|"ActivatePaneByIndex"...(+76))?`
          - Type `ActionFuncClass` cannot match `nil`
          - Type `ActionFuncClass` cannot match `"TogglePaneZoomState"`
          - Type `ActionFuncClass` cannot match `"ToggleFullScreen"`
          - Type `ActionFuncClass` cannot match `"SwitchWorkspaceRelative"`
          - Type `ActionFuncClass` cannot match `"SwitchToWorkspace"`
          - Type `ActionFuncClass` cannot match `"StartWindowDrag"`
          - Type `ActionFuncClass` cannot match `"SplitVertical"`
          - Type `ActionFuncClass` cannot match `"SplitPane"`
          - Type `ActionFuncClass` cannot match `"SplitHorizontal"`
          - Type `ActionFuncClass` cannot match `"SpawnWindow"`
          ...(+69)
          - Type `ActionFuncClass` cannot match `"ActivateKeyTable"`
          - Type `ActionFuncClass` cannot match `"ActivateCopyMode"`
          - Type `ActionFuncClass` cannot match `"ActivateCommandPalette"` Lua Diagnostics. (assign-type-mismatch) [22, 3]

Expected Types

I expect no type warnings to appear for such a common configuration use-case.

Additional Info and/or Screenshots

No response

Metadata

Metadata

Assignees

Labels

missing-typesMissing data types foundsolvedIssue is solved (or at least marked as solved)wrong-typesWrong type has been found

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions