Skip to content

feat(liquid-doc): support union types and string literal types in @param annotations#1242

Open
andershagbard wants to merge 2 commits into
Shopify:mainfrom
andershagbard:feat/doc-union-literal-types
Open

feat(liquid-doc): support union types and string literal types in @param annotations#1242
andershagbard wants to merge 2 commits into
Shopify:mainfrom
andershagbard:feat/doc-union-literal-types

Conversation

@andershagbard

Copy link
Copy Markdown
Contributor

Summary

  • Union types: @param {string|number} size — a param can now accept multiple named types separated by |
  • String literal types: @param {'banner'|'label'} variant — a param can be constrained to specific string values
  • Mixed unions: @param {string|'banner'|'label'} value — named types and literals can be combined freely

Both single and double quotes are supported for string literals.

Changes

theme-check-common

  • parseParamType() — splits on |, validates each member as a quoted string literal or a known named type
  • isTypeCompatible() — iterates union members; literal members are compatible with string args; boolean still accepts any type
  • getDefaultValueForType() — uses the first literal member as the default for literal unions (e.g. 'banner'|'label''banner'), otherwise uses the first named type's default
  • findTypeMismatchParams() — removes the skip guard that silently ignored any type not in BasicParamTypes, so union/literal types now get type-checked at call sites

theme-language-server-common

  • LiquidDocParamTypeCompletionProvider — extends the trigger regex from /^\{[a-zA-Z]*$/ to /^\{[a-zA-Z'"|]*$/ so completions fire after | and inside quoted literals

Tests

  • utils.spec.ts — new cases for parseParamType, isTypeCompatible, and getDefaultValueForType covering unions, literals, mixed unions, and invalid inputs
  • valid-doc-param-types/index.spec.ts — new cases for union and literal types passing validation, and a union with an invalid member reporting an error

🤖 Generated with Claude Code

https://claude.ai/code/session_01T7YveNnZpURm8j81wUDK7D

andershagbard and others added 2 commits June 14, 2026 15:00
…rguments

When a render tag uses a filter expression as a named argument value
(e.g. `render 'snippet', for: block.id | append: '-list'`), the parser
was falling back to the base-case `LiquidTag` with a string markup
instead of producing a structured `RenderMarkup` node.

This happened because `renderArguments` used `tagArguments` which only
allowed `liquidExpression` (no filters) as argument values. The leftover
`| append: '-list'` caused `liquidTagRender` to fail, triggering
base-case fallback.

Add `renderTagArguments`, `renderTagNamedArgument`, and
`renderTagArgumentValue` rules that consume filter chains in named
argument values. `renderTagArgumentValue` is like `liquidVariable` but
without the `&delim` lookahead at the end, allowing it to work for both
last and non-last named arguments in a list.

This fixes a false positive in the `OrphanedSnippet` check: snippets
rendered via a tag with filter expressions in named arguments were
incorrectly reported as orphaned because the theme graph traversal
(which relies on `RenderMarkup` nodes) never saw the render reference.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…iquidDoc @param

Adds support for union types (e.g. {string|number}) and string literal
types (e.g. {'banner'|'label'}) in {% doc %} @param annotations.

- parseParamType: accepts | separated members, validates each as a named
  type or quoted string literal
- isTypeCompatible: returns true if actual type matches any union member;
  literals are compatible with string args
- getDefaultValueForType: uses first literal as default for literal unions
- findTypeMismatchParams: removes skip guard that silently ignored
  non-basic types, so union/literal types now get type-checked
- LiquidDocParamTypeCompletionProvider: trigger regex extended to fire
  after | and inside quoted literals

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T7YveNnZpURm8j81wUDK7D
@andershagbard andershagbard requested a review from a team as a code owner June 20, 2026 10:11
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