Skip to content

feat: TypeScript foundation setup#22

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1776394144-typescript-foundation
Open

feat: TypeScript foundation setup#22
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1776394144-typescript-foundation

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 17, 2026

Summary

Sets up TypeScript infrastructure for the Next.js project so subsequent migration sessions can proceed. All existing .js/.jsx files continue to work via allowJs: true.

Changes:

  • Installed typescript@5, @types/react@17, @types/react-dom@17, @types/node as devDependencies
  • Created tsconfig.json with strict: true and all requested compiler options (Next.js auto-appended target, lib, forceConsistentCasingInFileNames on first build)
  • Removed .babelrc and uninstalled @babel/core + @babel/preset-react (Next.js 12 uses SWC by default)
  • Created types/index.ts with shared SanityProduct, CartItem, and SanityBanner interfaces derived from the Sanity schemas
  • Added next-env.d.ts (generated by Next.js) and *.tsbuildinfo to .gitignore

Version choices:

  • TypeScript 5.x (not 6.x): TS 6 deprecates moduleResolution: "node" and errors on it; TS 5 is the latest stable that supports the requested tsconfig without changes.
  • @types/react@17.0.39 (not latest): Newer @types/react versions add an exports field that breaks Next.js 12's require.resolve('@types/react/index.d.ts') detection, causing the build to fail. 17.0.x is also the correct match for the project's React 17 runtime.

Verification results:

  • npx tsc --noEmit — no errors
  • npm run build — compiles and generates all pages successfully
  • npm run dev — starts without errors on localhost
  • .babelrc deleted, @babel/core and @babel/preset-react absent from package.json
  • tsconfig.json contains "strict": true
  • types/index.ts exports SanityProduct, CartItem, SanityBanner

Review & Testing Checklist for Human

  • Verify tsconfig.json settings are acceptable — Next.js auto-added target: "es5", lib, and forceConsistentCasingInFileNames on top of the requested options. Confirm these additions are fine.
  • Confirm TypeScript 5.x is acceptable — TS 6 breaks with moduleResolution: "node". If TS 6 is required, the tsconfig would need moduleResolution: "bundler" instead.
  • Confirm @types/react@17 is acceptable — matches the React 17 runtime, but later migration sessions upgrading React may need to bump this.
  • Verify types/index.ts matches Sanity schemas — cross-check SanityProduct / SanityBanner fields against sanity_ecommerce/schemas/product.js and sanity_ecommerce/schemas/banner.js.
  • Run npm run build and npm run dev locally to confirm the app works end-to-end.

Notes

  • @babel/core was listed under dependencies (not devDependencies) in the original package.json. It has been removed from there. @babel/preset-react was in devDependencies and is also removed.
  • --legacy-peer-deps was required during npm install due to a pre-existing peer dependency conflict (next-sanity-image expects @sanity/client@^2 but ^3 is installed).

Link to Devin session: https://app.devin.ai/sessions/7bf8288d22994c09befb752ab19d85d5
Requested by: @WesternConcrete


Open with Devin

- Install typescript, @types/react, @types/react-dom, @types/node as devDependencies
- Create tsconfig.json with strict mode enabled
- Remove .babelrc and Babel dependencies (@babel/core, @babel/preset-react)
- Create shared types file at types/index.ts with SanityProduct, CartItem, SanityBanner interfaces
- Add next-env.d.ts and .tsbuildinfo to .gitignore

Co-Authored-By: Wes Convery <2wconvery@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@devin-ai-integration
Copy link
Copy Markdown
Author

End-to-End Test Results

Ran dev server locally, tested homepage and product detail page in browser, verified TypeScript type-checking.

All 3 tests passed.

Test 1: Homepage renders after Babel removal — PASSED
  • Hero banner with "Summer Sale" visible
  • "Best Seller Products" heading present
  • All 5 product cards rendered (Speaker $56, Smartwatch $99, Cool In-ear headphones $40, Headphones $55, Headphones $99)
  • No Next.js error overlay or compilation errors

Homepage

Test 2: Product detail page (dynamic route + SSG) — PASSED
  • Navigated to /product/speaker via product card click
  • Product name "Speaker", price "$56", details, images, Add to Cart/Buy Now buttons all visible
  • "You may also like" section renders with other products

Product Detail

Test 3: tsc --noEmit — PASSED

npx tsc --noEmit exited with code 0, no type errors.


Devin session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant