hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

Fix the `OptimisticCart` type to properly retain the generic of line items

Open blittle opened this issue 1 year ago • 3 comments

WHY are these changes introduced?

@brookslybrand reported an issue where the the generic on OptimisticCart did not propagate to line items. For example, this would produce a type of the default cart lines, not the generic api fragment provided.

type CartLine = OptimisticCart<CartApiQueryFragment>['lines']['nodes'];

With this change, now the CartAPIQueryFragment is preserved.

Checklist

  • [X] I've read the Contributing Guidelines
  • [X] I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • [X] I've added a changeset if this PR contains user-facing or noteworthy changes
  • [X] I've added tests to cover my changes
  • [X] I've added or updated the documentation

blittle avatar Jul 12 '24 20:07 blittle

Oxygen deployed a preview of your bl-fix-optimistic-cart-types-2 branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
metaobjects ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
classic-remix ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:50 PM

Learn more about Hydrogen's GitHub integration.

shopify[bot] avatar Jul 12 '24 20:07 shopify[bot]

/snapit

blittle avatar Jul 12 '24 20:07 blittle

🫰✨ Thanks @blittle! Your snapshot has been published to npm.

Test the snapshot by updating your package.json with the newly published version:

"@shopify/hydrogen": "0.0.0-snapshot-20240712202726"

github-actions[bot] avatar Jul 12 '24 20:07 github-actions[bot]

I've experienced this as well! Would love to see it come in the next release :)

merrickread avatar Jul 31 '24 14:07 merrickread