Skip to content

Support string enums in LiquidDoc parameter types - #1310

Open
clauderic wants to merge 4 commits into
mainfrom
liquiddoc-string-literal-unions
Open

clauderic wants to merge 4 commits into
mainfrom
liquiddoc-string-literal-unions

Conversation

@clauderic

@clauderic clauderic commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

What are you adding in this PR?

LiquidDoc @param types can now be string enums:

{% doc %}
  @param {'heading' | 'small'} [variant] - Text style
{% enddoc %}
  • Theme Check accepts these declarations. It checks literal arguments to render (including with/for aliases), content_for and block against the allowed values, and suggests each allowed value as a replacement. When adding a missing required argument to render or content_for, it inserts the first allowed value. Dynamic values such as variables are not checked. Block parameters backed by a schema setting keep the setting's type, as in Validate block call parameters #1306.
  • The language server keeps the allowed values through assignments and default, shows them in hovers and completion docs, and inserts the first one in render and content_for parameter completions.
  • The parser no longer ends a LiquidDoc type at a } inside a quoted string. If a quote is left open, the type still ends at the first }, as before.

Enums are modeled as unions of string literal types rather than as a dedicated enum kind. Unions such as {string | number} or {product | collection} and discriminated unions (#223) can therefore build on this without another change to the model. For now, only string literals parse as union members.

The four commits are meant to be reviewed in order: parser fix, declarations, argument checks, language server.

What's next? Any followup issues?

  • General unions such as {string | number} and {product | collection}: the parser has to accept type names as union members, and the checks and type system need rules for mixed unions.
  • Discriminated unions: Support discriminated unions #223.
  • Enums on schema-backed block parameters: the setting's type wins, so an enum declared for a text or select setting is not enforced at call sites yet.

Tophatting

In a snippet snippets/text.liquid that declares the @param above:

  1. Hover {{ variant }}: it shows 'heading' | 'small'.
  2. Hover style after {% assign style = variant | default: 'heading' %}: it still shows 'heading' | 'small'.
  3. In a template, {% render 'text', variant: 'body' %} is reported, with suggestions to replace 'body' with 'heading' or 'small'.
  • I added screenshots of the changes (before and after the changes if applicable)

Before you deploy

  • I included a minor bump changeset
  • My feature is backward compatible
  • I included a patch bump changeset

🤖 Generated with Claude Code

@clauderic
clauderic requested a review from a team as a code owner September 29, 2026 19:51
@clauderic
clauderic force-pushed the liquiddoc-string-literal-unions branch from b24a75f to c038b0f Compare September 29, 2026 20:31

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant