feat(liquid-doc): support union types and string literal types in @param annotations#1242
Open
andershagbard wants to merge 2 commits into
Open
feat(liquid-doc): support union types and string literal types in @param annotations#1242andershagbard wants to merge 2 commits into
andershagbard wants to merge 2 commits into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@param {string|number} size— a param can now accept multiple named types separated by|@param {'banner'|'label'} variant— a param can be constrained to specific string values@param {string|'banner'|'label'} value— named types and literals can be combined freelyBoth single and double quotes are supported for string literals.
Changes
theme-check-commonparseParamType()— splits on|, validates each member as a quoted string literal or a known named typeisTypeCompatible()— iterates union members; literal members are compatible withstringargs; boolean still accepts any typegetDefaultValueForType()— uses the first literal member as the default for literal unions (e.g.'banner'|'label'→'banner'), otherwise uses the first named type's defaultfindTypeMismatchParams()— removes the skip guard that silently ignored any type not inBasicParamTypes, so union/literal types now get type-checked at call sitestheme-language-server-commonLiquidDocParamTypeCompletionProvider— extends the trigger regex from/^\{[a-zA-Z]*$/to/^\{[a-zA-Z'"|]*$/so completions fire after|and inside quoted literalsTests
utils.spec.ts— new cases forparseParamType,isTypeCompatible, andgetDefaultValueForTypecovering unions, literals, mixed unions, and invalid inputsvalid-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