gatsby-plugin-typescript allows Gatsby to process and build TypeScript and TSX files, integrating TypeScript transpilation into the Gatsby build pipeline using `@babel/preset-typescript`. The plugin's current stable version, 5.16.0, is designed for Gatsby v5, and its releases typically align with major and minor Gatsby core updates. A key differentiator is that this plugin focuses solely on transpilation, meaning it transforms TypeScript code into JavaScript without performing type checking itself. Developers are expected to handle type checking separately, often through their IDE or a dedicated `type-check` script. While it supports most common TypeScript features, it has specific limitations due to its Babel-based approach, such as not supporting namespaces, `const` enums, `export =`/`import =` syntax, or direct `baseUrl` configuration. The plugin is automatically included in Gatsby projects, requiring explicit configuration only for custom options.
npm install gatsby-plugin-typescriptVerified import paths — ran on the pinned version, not inferred.
This quickstart shows how to configure `gatsby-plugin-typescript` in `gatsby-config.js` and create a basic Gatsby page component using TypeScript and TSX syntax.
Upgrade your Node.js environment to a compatible version, preferably Node.js 20 or 22. Gatsby 5.16.0 officially supports Node.js 24.
Implement a separate type-checking step in your project. Add a script like `"type-check": "tsc --noEmit"` to your `package.json` and run it alongside or before your Gatsby build. Configure your IDE (e.g., VS Code) for real-time type error surfacing.
Adopt ES module syntax (`export default`, `export const`, `import x, {y} from "z"`), avoid `const` enums (or remove the `const` keyword), and use `gatsby-plugin-root-import` to handle path aliases similar to `baseUrl`.Install necessary type definitions as development dependencies, for example: `npm install --save-dev @types/react @types/react-dom @types/node`.
Upgrade your Node.js environment to a version compatible with Gatsby 5. The latest Gatsby releases support Node.js 22 and 24.
This is expected behavior for `gatsby-plugin-typescript`. To catch and enforce type correctness, run `tsc --noEmit` separately as a build step or rely on your IDE's TypeScript integration.
Install and configure `gatsby-plugin-root-import` (`npm install gatsby-plugin-root-import`) in your `gatsby-config.js` to enable path aliasing for module resolution during the Gatsby build.