theme-tools icon indicating copy to clipboard operation
theme-tools copied to clipboard

Improve doc typing when converting to array

Open bakura10 opened this issue 1 year ago • 6 comments

Hello,

Liquid currently lacks a lot in the array manipulation area, but there are a lot of tricks to workaround. One common trick is to create an array from a variable using the sort filter:

for media in product.media
  assign media_as_array = media | sort
endfor

Which then allows to concat it to another array. The issue is that currently the type is lost, so while media is properly typed as "media", after the sort operation it becomes untyped[]

Until we can have better array functions, could the typing be improved so that the type is preserved?

Thanks!

bakura10 avatar Nov 27 '25 07:11 bakura10

Thanks @bakura10! Moved this to theme-tools where the logic for this will be.

graygilmore avatar Nov 27 '25 17:11 graygilmore

Note for future devs, hint: https://github.com/Shopify/theme-liquid-docs/blob/main/data/filters.json#L3168-L3207

graygilmore avatar Nov 27 '25 17:11 graygilmore

Hi @graygilmore and @bakura10 👋,

I’ve forked the repo, cloned it locally, and set up my workspace in VS Code. I am looking into how type propagation is handled post-filter, especially around sort

Can you assign this one to me?

Thank you. All the best

cbueker-it avatar Nov 28 '25 16:11 cbueker-it

Hi @graygilmore 👋 — quick question:

I’m working on issue #1086 and I've run into a blocker while setting up the environment.

When running the tests in theme-check-docs-updater, I'm getting this Vite error:

Failed to resolve entry for package "@shopify/liquid-html-parser"

I tried:

Downgrading the version (e.g. 2.9.0, 2.8.0)

Adding it directly in theme-check-docs-updater

Checking the package.json in node_modules : It doesn’t seem to define a main or exports field.

Is there a recommended version of @shopify/liquid-html-parser to use with this monorepo? Or do I need to build it locally?

I can patch this temporarily if needed. Just want to be sure I'm heading the right direction before going further.

Thanks a lot!

cbueker-it avatar Nov 29 '25 01:11 cbueker-it

You might need to do a yarn build before running tests to ensure all dependencies are set up correctly in each package.

graygilmore avatar Dec 01 '25 18:12 graygilmore

Hi! I'd love to contribute. Could you assign this issue to me? Happy to get started right away.

mizoz avatar Apr 28 '26 18:04 mizoz