liquid
liquid copied to clipboard
[LiquidDoc] Add union types
Add the possibility to add union types for LiquidDocs.
E.g.
@param {string|number} my_variable - This can be a string or a number.
Use cases:
-
When passing an image aspect attribute, you can manually enter the numeric value as
0.5or you can enter a string as1/2, and then have the snippet to the math for you. -
To be a bit more lax. When passing a width attribute and appending
%. E.g.{{ width | append: '%' }}, you wouldn't care if it's a number or a string.
@karreiro (Tagging for visibility)
To add a usecase, using string literal union types (call it what you want):
A snippet containing a case that renders something based off what parameter is passed. I would like to restrict the parameter to only contain the cases we handle.
@param { 'banner' | 'label' } my_variable - A string that must be either 'banner' or 'label'.