feat: migrate composite components to TypeScript#28
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
feat: migrate composite components to TypeScript#28devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- Set up TypeScript foundation: tsconfig.json, types/index.ts, next-env.d.ts - Remove .babelrc and babel dependencies (replaced by Next.js SWC compiler) - Install typescript, @types/react, @types/react-dom, @types/node, @types/canvas-confetti - Migrate lib/ layer: client.ts, getStripe.ts, utils.ts with proper type annotations - Migrate context/ layer: StateContext.tsx with full StateContextType interface - Migrate leaf components: Footer.tsx, Product.tsx, HeroBanner.tsx, FooterBanner.tsx with typed props - Migrate composite components: Cart.tsx (typed useRef<HTMLDivElement>, async handleCheckout), Navbar.tsx, Layout.tsx (typed children: React.ReactNode) - Migrate components/index.js to components/index.ts barrel re-export Verification: - npx tsc --noEmit passes with zero errors - npm run build succeeds - No .jsx or .js files remain in components/ Co-Authored-By: Wes Convery <2wconvery@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Author
E2E Test ResultsRan the dev server locally and tested all critical user flows in the browser to verify the TypeScript migration didn't break runtime behavior. All 9 assertions passed. Core Functionality Tests
Key ScreenshotsHome PageProduct Detail PageAdd to Cart ToastCart SidebarQuantity IncrementEmpty Cart After Removal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full TypeScript migration of the project's component, context, and lib layers. Since no TypeScript foundation existed on
main, this PR includes the complete setup:tsconfig.json,next-env.d.ts,types/index.tswith shared interfaces (SanityProduct,CartItem,SanityBanner)typescript,@types/react@17,@types/react-dom@17,@types/node,@types/canvas-confetti. Removed@babel/coreand@babel/preset-react(Next.js 12 uses SWC by default). Deleted.babelrc.client.ts(typedurlForwithSanityImageSource),getStripe.ts(typedStripe | nullpromise),utils.ts(typed params)StateContext.tsxwith fullStateContextTypeinterface and typeduseStateContexthook (throws if used outside provider).jsx→.tsxwith typed props,React.FC, and proper genericscomponents/index.js→components/index.tsNote:
pages/directory files remain as.js(out of scope);allowJs: trueis set in tsconfig to support this.Behavioral changes beyond renaming (review carefully)
Cart.tsxresponse.statusCode→response.status.status, not.statusCodeCart.tsxstripe.redirectToCheckout→stripe?.redirectToCheckoutgetStripe()can returnnull; avoids potential runtime throwCart.tsxonClick=""on quantity<span>urlFor(...)→urlFor(...).url()StateContext.tsx.map()callback now returnscartProductfor non-matching itemsundefinedStateContext.tsxproduct.quantity = quantity→ spread{ ...product, quantity }Review & Testing Checklist for Human
urlFor(...).url()produces correct image URLs — previously the ImageUrlBuilder object was passed directly assrc(likely relying on implicit.toString()). Confirm images still render correctly on the home page, product pages, and cart.StateContext.tsxbehavioral fixes — the.map()fix (returningcartProductfor non-matches) and the mutation removal (product.quantity = quantity→ spread) change runtime behavior. Verify add-to-cart works correctly, especially adding a product that's already in the cart.response.statusCode → response.statusandstripe?.redirectToCheckoutchanges touch the payment path. Test a checkout to confirm it still redirects properly.!) onfoundProductintoggleCartItemQuanitityandonRemove— these assume the product is always found in the cart. If it's possible for it to be missing, these will throw at runtime.Suggested test plan: Run
npm run dev, browse products, add items to cart, adjust quantities, remove items, and attempt checkout. Confirm all images load and the cart state behaves correctly.Notes
npx tsc --noEmitpasses with zero errorsnpm run buildsucceeds (warnings are pre-existing, unrelated to this PR).jsxor.jsfiles remain incomponents/ignoreDeprecations: "6.0"is set in tsconfig to silence themoduleResolution: "node"deprecation warningLink to Devin session: https://app.devin.ai/sessions/ccd8d5b815264c1e80ea23b4c327b300
Requested by: @WesternConcrete