ValidRenderPartialArgumentTypes
ValidRenderPartialArgumentTypes
Severity: warning | Type: LiquidHtml | Aliases: ValidRenderPartialParamTypes
This check ensures that arguments passed to a partial match the expected types declared in the partial's {% doc %} tag. When a type mismatch is detected, the check reports it with a suggestion to fix the value.
The check handles both named arguments ({% render 'card', title: "Hello" %}) and the alias syntax ({% render 'card' with 123 as count %}).
Type checking is only performed when:
- The target partial has a
{% doc %}tag. - The
@paramentry includes a type annotation (e.g.@param {string} title). - The annotated type is one of
string,number,boolean,objectorarray— object types from the Liquid objects reference and[]-suffixed types are accepted in the annotation but not type-checked at the call site. - The argument value is a literal (string, number, boolean, array) — variable lookups and filtered values are not type-checked statically, since their type cannot be determined without running the code.
Two types are deliberately permissive:
booleanaccepts any value, because every value in Liquid is truthy or falsy.objectaccepts an array as well as an object, because it stands for anything that is not a primitive. Annotate a parameter asarraywhen you want a non-list argument to be reported.
nil and null are accepted for every type — they mean "no value".
Examples
✗ Incorrect Code Example (Avoid using this):
{% comment %}app/views/partials/count-badge.liquid{% endcomment %}
{% doc %}
@param {number} count - Number of items to display
{% enddoc %}
<span class="badge">{{ count }}</span>
{% comment %}Calling site — passing a string where a number is expected{% endcomment %}
{% render 'count-badge', count: "five" %}
✓ Correct Code Example (Use this instead):
{% render 'count-badge', count: 5 %}
{% render 'count-badge', count: item.count %}
Arrays
{% comment %}app/views/partials/tag-list.liquid{% endcomment %}
{% doc %}
@param {array} tags - Tags to display
{% enddoc %}
{% comment %}Error — expected array, got string{% endcomment %}
{% render 'tag-list', tags: 'news' %}
{% comment %}OK{% endcomment %}
{% render 'tag-list', tags: ['news', 'events'] %}
Configuration
The default configuration for this check:
ValidRenderPartialArgumentTypes:
enabled: true
severity: warning
Disabling This Check
This check is safe to disable if your codebase passes values of different types intentionally and relies on Liquid's dynamic type coercion.