Fix the `OptimisticCart` type to properly retain the generic of line items
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
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.
/snapit
🫰✨ 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"
I've experienced this as well! Would love to see it come in the next release :)