Skip to content

Decide on how to handle TypeScript for Gatsby plugins and themes #950

@jxnblk

Description

@jxnblk

Based on discussion in #668, we should decouple the TypeScript conversion of Gatsby-related packages from the core packages, due to how Gatsby currently handles TypeScript in plugins.

Currently, the plugins and themes are written in standard JavaScript, and Gatsby uses these packages as-is, without a compilation step needed in this repo. This can be beneficial for users who "eject" (copy and paste) files from these plugins and themes, when using Gatsby's shadowing feature, because it means the files copied over are the same as they are written.

In the future, once Gatsby supports TypeScript language in plugins, we should still consider backwards compatibility and those who use Gatsby with JavaScript -- introducing another language could be unexpected.

There are several PRs already in-progress for converting these packages, and they should remain open until a solution is decided upon:

Potential solutions

Off the top of my head, there are a few ways to handle this, but I'm open to hearing more suggestions:

  1. Keep all Gatsby related packages written in JavaScript -- this is not ideal for TypeScript users
  2. Convert packages to TypeScript and add a compilation step -- this is probably not ideal for anyone
  3. Add type definitions for the packages, but keep them written in JavaScript -- I'm unsure of how big the downside is, but TypeScript users who eject files would still get JavaScript
  4. Create separate TypeScript-specific packages in addition to the JavaScript ones -- this has a bigger maintenance cost
  5. Wait for future support in Gatsby that could help with this -- it's unclear what this would look like or how long this would take

Additional context

Some of these packages have very low usage and are somewhat experimental:

  • gatsby-theme-code-recipes: 1 download per week (I think it's theme-ui.com)
  • gatsby-theme-ui-layout: 28 downloads per week
  • gatsby-theme-ui-blog: 88 downloads per week

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions