Improve doc typing when converting to array
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!
Thanks @bakura10! Moved this to theme-tools where the logic for this will be.
Note for future devs, hint: https://github.com/Shopify/theme-liquid-docs/blob/main/data/filters.json#L3168-L3207
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
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!
You might need to do a yarn build before running tests to ensure all dependencies are set up correctly in each package.
Hi! I'd love to contribute. Could you assign this issue to me? Happy to get started right away.