feat: migrate leaf components to TypeScript#23
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
feat: migrate leaf components to TypeScript#23devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…ner) to TypeScript - Install TypeScript, @types/react, @types/react-dom, @types/node - Remove .babelrc and babel dependencies (replaced by Next.js SWC compiler) - Add tsconfig.json with strict mode enabled - Create types/index.ts with SanityProduct, CartItem, and SanityBanner interfaces - Rename Footer.jsx -> Footer.tsx with React.FC typing - Rename Product.jsx -> Product.tsx with ProductProps interface - Rename HeroBanner.jsx -> HeroBanner.tsx with HeroBannerProps interface - Rename FooterBanner.jsx -> FooterBanner.tsx with FooterBannerProps interface Verification: - npx tsc --noEmit: passes with no errors - npm run build: succeeds 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
Testing ResultsRan the app locally ( All 5 tests passed:
Build verification
|
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
Adds TypeScript support to the project and migrates the four leaf-level React components (
Footer,Product,HeroBanner,FooterBanner) from JSX to TSX with typed props.Infrastructure changes:
typescript@^6.0.3,@types/react@^17.0.39,@types/react-dom@^17.0.11,@types/node.babelrcand Babel dependencies (@babel/core,@babel/preset-react) — Next.js 12 SWC handles compilationtsconfig.jsonwithstrict: trueandallowJs: truefor incremental adoptiontypes/index.tswith sharedSanityProduct,CartItem, andSanityBannerinterfacesComponent migrations:
Footer.tsx— typed asReact.FC(no props)Product.tsx—ProductPropsinterface withproduct: SanityProductHeroBanner.tsx—HeroBannerPropsinterface withheroBanner: SanityBannerFooterBanner.tsx—FooterBannerPropsinterface withfooterBanner: SanityBannernpx tsc --noEmitandnpm run buildboth pass.Review & Testing Checklist for Human
urlFor()casts are safe —urlFor()returns anImageUrlBuilder, not astring. The original JSX relied on implicit coercion; this PR usesas unknown as stringto silence TS. Confirm this works at runtime (it should, viatoString()), and consider whether calling.url()on the builder would be a cleaner long-term fix.@babel/corewas listed underdependencies(notdevDependencies). Verify no other part of the app or tooling depends on it.npm run dev, navigate the storefront, and verify product cards, hero banner, footer banner, and footer all render correctly.Notes
tsconfig.jsonusesmoduleResolution: "node10"withignoreDeprecations: "6.0"to suppress a TS 6.x deprecation warning for the Node resolution strategy, which is required for compatibility with Next.js 12.@types/reactis pinned to^17.0.39because newer versions include anexportsmap that breaks Next.js 12's type detection.CartIteminterface intypes/index.tsis not used by any migrated component but is included for use by future migrations (e.g.,Cart.jsx, context).Link to Devin session: https://app.devin.ai/sessions/cadd4a6658b94488bb8cc9dfaa72f0d0
Requested by: @WesternConcrete