Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

Advice on Migrating a Gatsby Site to Typescript

6 replies
Last updated: May 12, 2021

Hey there, I was wondering if anyone has any experience, or advice on incrementally migrating a Gatsby site to Typescript? I’ve done a few searches, and not had a lot of luck. There’s lots on how to start a Gatsby site using TS, but I couldn’t find anything on actually migrating, least of all piece by piece.

May 12, 2021, 5:42 PM

nothing is stopping you from having JSX and TSX files

May 12, 2021, 5:42 PM

you can migrate components one at a time

May 12, 2021, 5:42 PM

for components that are really not

ts fun
i leave them js/jsx

May 12, 2021, 5:43 PM

Perfect! I’ve been a bit worried that it wouldn’t compile correctly, or that there’d be a bunch of build errors - but I’d really like to make the migration happen. So I plan to build my new features in TS, and the update the existing components as time allows.

May 12, 2021, 5:44 PM

yeah should support it so long as you have the ts package or on the gatsby that supports ts out of the box

May 12, 2021, 5:45 PM

Awesome! Thanks, Kev! And while I’m at it, thanks for all of the work that you do around here. I have been following your work for awhile, and it has been really helpful. Particularly the headless Shopify stuff. 🤘

May 12, 2021, 5:48 PM Get the most out of your content is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.