Shopify / theme-tools

Everything developer experience for Shopify themes
https://shopify.dev/docs/themes
MIT License
80 stars 24 forks source link

Figure out a way to prevent incompatible/breaking Shopify/theme-liquid-docs JSON schema changes #601

Open charlespwd opened 1 week ago

charlespwd commented 1 week ago

With #599, we added strict typing of {% schema %} tag parsed content.

We use the JSON Schemas defined over in Shopify/theme-liquid-docs as a type assertion.

Problem with this is that Shopify/theme-liquid-docs is meant to change independently of our codebase. It's that way so that we can ship changes without requiring a release.

This is mostly fine since the types are used inside checks/completion internally and we wouldn't be using types that don't exist yet.

The only problem I can see happening is with changes like the one we recently shipped: accepting blocks presets as a hash rather than an array. This kind of change would make something we strictly type to be an array be an object at runtime. Since the validation is injected, then the "type assertion" would incorrectly say that the parsed object has an array blocks property when it could be array or hash.

We'll need some kind of process to prevent against issues like these.