Skip to content

LuaLS-style quoted literal aliases cause false type mismatches #1271

Closed as not planned

Description

@oriori1703

Description

LuaLS-style string literal aliases use an outer single-quoted annotation string around a quoted literal, for example ---| '"fallback"'. EmmyLua accepts the syntax but does not match the Lua value 'fallback' against it, causing a false param-type-mismatch.

This affects existing Neovim plugin annotations. For example, stevearc/conform.nvim defines conform.LspFormatOpts this way, so its documented default_format_opts = { lsp_format = 'fallback' } configuration is reported as incompatible with conform.setupOpts.

Minimal reproduction

.emmyrc.json:

{}

repro.lua:

---@alias LspFormat
---| '"never"'
---| '"fallback"'

---@class (exact) DefaultOpts
---@field lsp_format? LspFormat

---@class (exact) SetupOpts
---@field default_format_opts? DefaultOpts

---@param opts? SetupOpts
local function setup(opts) end

setup {
  default_format_opts = {
    lsp_format = 'fallback',
  },
}

Run:

emmylua_check .

Actual behavior

warning: expected `SetupOpts?` but found `{ default_format_opts = table }`. [param-type-mismatch]

The same mismatch is reported by emmylua_ls when configuring Conform:

expected `conform.setupOpts?` but found `{ default_format_opts = table }`. [param-type-mismatch]

Expected behavior

No type mismatch. This literal alias spelling is used by LuaLS annotations in existing Lua projects and should describe the value fallback, not a string containing quote characters.

Changing the alias to EmmyLua's spelling makes the reproduction pass:

---@alias LspFormat
---| "never"
---| "fallback"

Environment

Activity

  1. CppCXY commented on Oct 3, 2026

    @CppCXY
    Member

    This syntax is actually not recommended for use. This syntax originally came from intellij-emmylua. Later, when the sumnek asked me about the syntax format for alias, I gave this version as an answer. This version is not very good. The version most people commonly use is the one without the middle quotation marks, so I set things right and removed support for this redundant version.

  2. oriori1703 commented on Oct 3, 2026

    @oriori1703
    Author

    sorry for this issue - I accidentally let my agent open issues and PR when debugging emmylua warnings from nvim-lua/kickstart.nvim#2163, instead of just triaging the issues.

    I'm closing this in favor of a fix in conform (stevearc/conform.nvim#902).
    again, sorry for the spam and thanks for the quick response :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions