question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Umbrella] TypeScript Migration (Help wanted!)

See original GitHub issue

Hello Community!

Gatsby is rewriting our core codebase in TypeScript! Checkout the RFC: #21798

We would love love love your help! This work is incredibly important in Gatsby being a stable product and you could be a part of it! We are looking for community members who would be willing to jump into the codebase in transition files from .js to .ts and add the proper typings. We have a few guidelines we are wanting to stick to when doing this:

Gatsby TS Guidelines

  • Only use named exports, no export default.
  • When importing a package, always try to find community maintained types instead of typing ourselves. Look at the DefinitelyTyped github repository.
  • Opt for using Interfaces for objects and functions.
  • Type aliases should be used for primitives, unions and tuples
  • Interface declaration merging is an anti-pattern and should not be used internally.
  • Use Array<type> rather than type[] syntax, as it’s clearer and matches built-in types such as Map.
  • Use TypeScript’s helper types, such as Record, rather than defining your own.
  • Every function should type its input and output (even if it’s inferrable)
  • Enums are great, but beware they map to index numbers if not redefined. This can cause weird problems for public APIs that interop to normal JS.
  • The any type can be used for stubbing module types that would be out of scope to migrate. But it should not be used for any functional input/outputs. The end goal of this migration is to have ZERO any types in the codebase. See if unknown makes more sense in that context. Don’t use @ts-ignore comments.
  • Lastly and most imporantly, we want to have simple types whenever possible. Primarily we should try to avoid Generics. Generic code can be highly reusable, but that can also come with the greater chance of breaking things. If you do need to use generics, please either give them default values or ensure the generic value can be inferred. Code should be simple when possible. DRY is not always best.

If you’re interested in getting involved, check out the list below. If you’re interested in doing something, please respond as a comment, i’ll put your name by a file so others know it’s “claimed”, when the PR is merged i’ll check the box.

Tips to get involved: first read the contribution docs, and see how to set up your local environment. After you’ve claimed the file to work on, convert it locally and ensure there are no typing or lint errors displayed in your IDE. Run yarn typecheck and yarn lint:code in the root before opening the PR, which will show any errors. Once you’re ready, open the PR and one of us will review it. Thanks, and good luck!

File list







  • packages/gatsby-link (@herecydev in #22027)
    • src/
      • /index.js + test
      • /parse-path.js + test

  • packages/gatsby-page-utils
    • src/
      • /create-path.js + test
      • /ignore-path.js + test
      • /index.js
      • /validate-path.js + test
      • /watch-directory.js


  • packages/gatsby-react-router-scroll (@blainekasten in #24306)
    • src/
      • /index.js
      • /ScrollBehaviorContext.js
      • /ScrollContainer.js
      • /StateStorage.js

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:53
  • Comments:141 (100 by maintainers)

github_iconTop GitHub Comments

20reactions
blainekastencommented, May 21, 2020

Huge milestone! gatsby-cli is 100% converted to TypeScript! Thank you everyone for your incredible work 💜💜💜

5reactions
blainekastencommented, Apr 17, 2020

Hello everyone!

Just wanted to drop in and say a HUUUUUUGE thank you! The response from the community has been amazing and (a little) overwhelming 😅. But keep it coming! Ya’ll are invaluable and speeding up this conversion 100x.

  • To those who have submitted PR’s, thank you!
  • To those who’s PRs have not yet been reviewed, we will get there! Some take more work than others and we have a lot to work through (including other features we want to launch for everyone!)
  • To those looking to get involved, please do! Don’t hesitate to put your name on a file in the description and start working on it. We want everyone’s involvement.

We’re making great progress. Let’s keep it up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript migration - Strict type of cocktails
Software Engineers deal with migrations at some point or another, and there are always a lot of lessons learned afterward.
Read more >
How can Umbrella organizations be migrated from one ...
It is possible for Umbrella Support to do the following: migrate/move a standalone org to a console;; migrate a child org from its...
Read more >
Migrating to Apollo Client 3.0 - Apollo GraphQL Docs
This article walks you through migrating your application to Apollo Client 3.0 from previous versions of Apollo Client. To illustrate the migration process, ......
Read more >
Documentation - Migrating from JavaScript - TypeScript
During our JS to TS migration, we'll need to separate our input files to prevent TypeScript from overwriting them. If your output files...
Read more >
Gatsby Changelog | 5.3.0
Earlier this year, we also included support for TypeScript, allowing you to author your ... please go to our ESM in Gatsby files...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found