feat: TypeScript foundation setup#22
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
- 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>
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
End-to-End Test ResultsRan 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
Test 2: Product detail page (dynamic route + SSG) — PASSED
Test 3: tsc --noEmit — PASSED
|
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
Sets up TypeScript infrastructure for the Next.js project so subsequent migration sessions can proceed. All existing
.js/.jsxfiles continue to work viaallowJs: true.Changes:
typescript@5,@types/react@17,@types/react-dom@17,@types/nodeas devDependenciestsconfig.jsonwithstrict: trueand all requested compiler options (Next.js auto-appendedtarget,lib,forceConsistentCasingInFileNameson first build).babelrcand uninstalled@babel/core+@babel/preset-react(Next.js 12 uses SWC by default)types/index.tswith sharedSanityProduct,CartItem, andSanityBannerinterfaces derived from the Sanity schemasnext-env.d.ts(generated by Next.js) and*.tsbuildinfoto.gitignoreVersion choices:
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/reactversions add anexportsfield that breaks Next.js 12'srequire.resolve('@types/react/index.d.ts')detection, causing the build to fail.17.0.xis also the correct match for the project's React 17 runtime.Verification results:
npx tsc --noEmit— no errorsnpm run build— compiles and generates all pages successfullynpm run dev— starts without errors on localhost.babelrcdeleted,@babel/coreand@babel/preset-reactabsent frompackage.jsontsconfig.jsoncontains"strict": truetypes/index.tsexportsSanityProduct,CartItem,SanityBannerReview & Testing Checklist for Human
tsconfig.jsonsettings are acceptable — Next.js auto-addedtarget: "es5",lib, andforceConsistentCasingInFileNameson top of the requested options. Confirm these additions are fine.moduleResolution: "node". If TS 6 is required, the tsconfig would needmoduleResolution: "bundler"instead.@types/react@17is acceptable — matches the React 17 runtime, but later migration sessions upgrading React may need to bump this.types/index.tsmatches Sanity schemas — cross-checkSanityProduct/SanityBannerfields againstsanity_ecommerce/schemas/product.jsandsanity_ecommerce/schemas/banner.js.npm run buildandnpm run devlocally to confirm the app works end-to-end.Notes
@babel/corewas listed underdependencies(notdevDependencies) in the originalpackage.json. It has been removed from there.@babel/preset-reactwas indevDependenciesand is also removed.--legacy-peer-depswas required duringnpm installdue to a pre-existing peer dependency conflict (next-sanity-imageexpects@sanity/client@^2but^3is installed).Link to Devin session: https://app.devin.ai/sessions/7bf8288d22994c09befb752ab19d85d5
Requested by: @WesternConcrete