Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gatsby-plugin-typescript

gatsbyjs1.2mMIT5.15.0

Adds TypeScript support to Gatsby

gatsby, gatsby-plugin, typescript

readme

gatsby-plugin-typescript

Allows Gatsby to build TypeScript and TSX files. Does NOT run type checking during build (see Caveats).

This plugin is automatically included in Gatsby. The only reason you would need to explicitly use this plugin is if you need to configure its options.

How to customize usage

  1. Include the plugin in your gatsby-config.js file with the specific options
  2. Write your components in TSX or TypeScript.
  3. Run TypeScript directly or with a build tool.
  4. You're good to go.

When creating pages programmatically, you can pass the .tsx filename directly as the component for createPage.

Please note: If packages don't ship with TypeScript definitions you'll need to manually install those type definitions, e.g. for React. A typical Gatsby project would need: npm install --save-dev @types/react @types/react-dom @types/node

Options

When adding this plugin to your gatsby-config.js, you can pass in options to override the default @babel/preset-typescript config.

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-typescript`,
      options: {
        isTSX: true, // defaults to false
        jsxPragma: `jsx`, // defaults to "React"
        allExtensions: true, // defaults to false
      },
    },
  ],
}

For more detailed documentation on the available options, visit https://babeljs.io/docs/en/babel-preset-typescript#options. To add TypeScript Babel plugins (e.g. @babel/plugin-proposal-decorators), you can try using a custom .babelrc file.

Caveats

This plugin uses babel-plugin-transform-typescript to transpile TypeScript. It does not do type checking. Also since the TypeScript compiler is not involved, the following applies:

Does not support namespaces. Workaround: Move to using file exports, or migrate to using the module { } syntax instead.

Does not support const enums because those require type information to compile. Workaround: Remove the const, which makes it available at runtime.

Does not support export = and import =, because those cannot be compiled to ES.next. Workaround: Convert to using export default and export const, and import x, {y} from "z".

Does not support baseUrl. Workaround: use gatsby-plugin-root-import and configure it to point the baseUrl value (also set baseUrl option in tsconfig.json file).

https://babeljs.io/docs/en/babel-plugin-transform-typescript.html

Type checking

First of all you should set up your IDE so that type errors are surfaced. Visual Studio Code is very good in this regard.

In addition, you can see the instructions in TypeScript-Babel-Starter for setting up a type-check task.

changelog

Changelog: gatsby-plugin-typescript

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

5.14.0 (2024-11-06)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.13.1 (2024-01-23)

Note: Version bump only for package gatsby-plugin-typescript

5.13.0 (2023-12-18)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.12.1 (2023-10-26)

Note: Version bump only for package gatsby-plugin-typescript

5.12.0 (2023-08-24)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.11.0 (2023-06-15)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.10.0 (2023-05-16)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.9.0 (2023-04-18)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.8.0 (2023-03-21)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.7.0 (2023-02-21)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.6.0 (2023-02-07)

🧾 Release notes

Bug Fixes

5.5.0 (2023-01-24)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.4.0 (2023-01-10)

🧾 Release notes

Chores

5.3.1 (2022-12-14)

Note: Version bump only for package gatsby-plugin-typescript

5.3.0 (2022-12-13)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.2.0 (2022-11-25)

🧾 Release notes

Other Changes

5.1.0 (2022-11-22)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

5.0.0 (2022-11-08)

🧾 Release notes

Chores

Other Changes

  • Revert "chore(gatsby-plugin-typescript): Remove obsolete onCreateWebpackConfig (#36814)" #36814 #36869 (24c185e)

4.24.0 (2022-09-27)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.23.0 (2022-09-13)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.22.0 (2022-08-30)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.21.0 (2022-08-16)

🧾 Release notes

Bug Fixes

  • only use resourceQuery for supported version of gatsby #36328 (564a8f7)

4.20.0 (2022-08-02)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.19.0 (2022-07-19)

🧾 Release notes

Features

4.18.1 (2022-07-12)

Note: Version bump only for package gatsby-plugin-typescript

4.18.0 (2022-07-05)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.17.0 (2022-06-21)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.16.0 (2022-06-07)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.15.0 (2022-05-24)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.14.0 (2022-05-10)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.13.0 (2022-04-26)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.12.1 (2022-04-13)

Note: Version bump only for package gatsby-plugin-typescript

4.12.0 (2022-04-12)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.11.1 (2022-03-31)

Note: Version bump only for package gatsby-plugin-typescript

4.11.0 (2022-03-29)

🧾 Release notes

Chores

  • replace all uses of gatsbyjs.org with gatsbyjs.com #35101 (16cff41)

4.10.1 (2022-03-23)

Note: Version bump only for package gatsby-plugin-typescript

4.10.0 (2022-03-16)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.9.1 (2022-03-09)

Note: Version bump only for package gatsby-plugin-typescript

4.9.0 (2022-03-01)

🧾 Release notes

Chores

4.8.2 (2022-03-01)

Note: Version bump only for package gatsby-plugin-typescript

4.8.1 (2022-02-25)

Note: Version bump only for package gatsby-plugin-typescript

4.8.0 (2022-02-22)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.7.0 (2022-02-08)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.6.0 (2022-01-25)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.5.2 (2022-01-17)

Note: Version bump only for package gatsby-plugin-typescript

4.5.1 (2022-01-12)

Note: Version bump only for package gatsby-plugin-typescript

4.5.0 (2022-01-11)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.4.0 (2021-12-14)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.3.0 (2021-12-01)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.2.0 (2021-11-16)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.1.3 (2021-11-15)

Note: Version bump only for package gatsby-plugin-typescript

4.1.2 (2021-11-11)

Note: Version bump only for package gatsby-plugin-typescript

4.1.1 (2021-11-10)

Note: Version bump only for package gatsby-plugin-typescript

4.1.0 (2021-11-02)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

4.0.0 (2021-10-21)

🧾 Release notes

Chores

3.14.0 (2021-09-18)

🧾 Release notes

Chores

Other Changes

  • Revert "chore(release): Publish next" (a0c4d44)

3.13.0 (2021-09-01)

🧾 Release notes

Chores

3.12.0 (2021-08-18)

🧾 Release notes

Chores

3.11.0 (2021-08-04)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

3.10.0 (2021-07-20)

🧾 Release notes

Chores

3.9.0 (2021-07-07)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

3.8.0 (2021-06-23)

🧾 Release notes

Chores

3.7.1 (2021-06-10)

Chores

3.7.0 (2021-06-09)

🧾 Release notes

Chores

3.6.0 (2021-05-25)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

3.5.0 (2021-05-12)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

3.4.0 (2021-04-28)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

3.3.0 (2021-04-14)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

3.2.0 (2021-03-30)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

3.1.0 (2021-03-16)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

3.0.0 (2021-03-02)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

2.12.1 (2021-02-24)

Note: Version bump only for package gatsby-plugin-typescript

2.12.0 (2021-02-02)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

2.11.0 (2021-01-20)

🧾 Release notes

Bug Fixes

2.10.0 (2021-01-06)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

2.9.0 (2020-12-15)

🧾 Release notes

Chores

2.8.0 (2020-12-02)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

2.7.0 (2020-11-20)

🧾 Release notes

Chores

2.6.0 (2020-11-12)

🧾 Release notes

Note: Version bump only for package gatsby-plugin-typescript

2.5.0 (2020-11-02)

Features

2.4.25 (2020-10-28)

Note: Version bump only for package gatsby-plugin-typescript

2.4.24 (2020-10-21)

Bug Fixes

  • Update plugin schema testing util and associated tests (#27574) (6d81283)

2.4.23 (2020-10-20)

Note: Version bump only for package gatsby-plugin-typescript

2.4.22 (2020-10-15)

Features

2.4.21 (2020-09-28)

Note: Version bump only for package gatsby-plugin-typescript

2.4.20 (2020-09-15)

Note: Version bump only for package gatsby-plugin-typescript

2.4.19 (2020-09-08)

Note: Version bump only for package gatsby-plugin-typescript

2.4.18 (2020-08-10)

Note: Version bump only for package gatsby-plugin-typescript

2.4.17 (2020-08-06)

Note: Version bump only for package gatsby-plugin-typescript

2.4.16 (2020-07-20)

Note: Version bump only for package gatsby-plugin-typescript

2.4.15 (2020-07-15)

Note: Version bump only for package gatsby-plugin-typescript

2.4.14 (2020-07-09)

Note: Version bump only for package gatsby-plugin-typescript

2.4.13 (2020-07-03)

Note: Version bump only for package gatsby-plugin-typescript

2.4.12 (2020-07-02)

Note: Version bump only for package gatsby-plugin-typescript

2.4.11 (2020-07-02)

Note: Version bump only for package gatsby-plugin-typescript

2.4.10 (2020-07-01)

Note: Version bump only for package gatsby-plugin-typescript

2.4.9 (2020-07-01)

Note: Version bump only for package gatsby-plugin-typescript

2.4.8 (2020-06-24)

Note: Version bump only for package gatsby-plugin-typescript

2.4.7 (2020-06-22)

Note: Version bump only for package gatsby-plugin-typescript

2.4.6 (2020-06-09)

Note: Version bump only for package gatsby-plugin-typescript

2.4.5 (2020-06-09)

Note: Version bump only for package gatsby-plugin-typescript

2.4.4 (2020-06-02)

Note: Version bump only for package gatsby-plugin-typescript

2.4.3 (2020-05-20)

Note: Version bump only for package gatsby-plugin-typescript

2.4.2 (2020-05-05)

Note: Version bump only for package gatsby-plugin-typescript

2.4.1 (2020-05-05)

Note: Version bump only for package gatsby-plugin-typescript

2.4.0 (2020-04-27)

Note: Version bump only for package gatsby-plugin-typescript

2.3.5 (2020-04-24)

Note: Version bump only for package gatsby-plugin-typescript

2.3.4 (2020-04-24)

Note: Version bump only for package gatsby-plugin-typescript

2.3.3 (2020-04-17)

Bug Fixes

2.3.2 (2020-04-16)

Note: Version bump only for package gatsby-plugin-typescript

2.3.1 (2020-03-23)

Note: Version bump only for package gatsby-plugin-typescript

2.3.0 (2020-03-20)

Features

2.2.5 (2020-03-16)

Note: Version bump only for package gatsby-plugin-typescript

2.2.4 (2020-03-16)

Note: Version bump only for package gatsby-plugin-typescript

2.2.3 (2020-03-13)

Note: Version bump only for package gatsby-plugin-typescript

2.2.2 (2020-03-07)

Bug Fixes

  • gatsby-plugin-typescript: Broader webpack support (#22003) (4b93826)

2.2.1 (2020-03-06)

Note: Version bump only for package gatsby-plugin-typescript

2.2.0 (2020-03-02)

Features

2.1.27 (2020-02-01)

Note: Version bump only for package gatsby-plugin-typescript

2.1.26 (2020-01-09)

Note: Version bump only for package gatsby-plugin-typescript

2.1.25 (2020-01-09)

Note: Version bump only for package gatsby-plugin-typescript

2.1.24 (2020-01-09)

Note: Version bump only for package gatsby-plugin-typescript

2.1.23 (2019-12-12)

Note: Version bump only for package gatsby-plugin-typescript

2.1.22 (2019-12-10)

Note: Version bump only for package gatsby-plugin-typescript

2.1.21 (2019-12-10)

Note: Version bump only for package gatsby-plugin-typescript

2.1.20 (2019-11-26)

Note: Version bump only for package gatsby-plugin-typescript

2.1.19 (2019-11-20)

Features

  • gatsby-plugin-typescript: add support for numeric separa… (#19610) (2921221)

2.1.18 (2019-11-15)

Note: Version bump only for package gatsby-plugin-typescript

2.1.17 (2019-11-13)

Features

  • gatsby-plugin-typescript: add support for optional chaining and nullish coalescing operator (#19302) (0647089)

2.1.16 (2019-11-10)

Note: Version bump only for package gatsby-plugin-typescript

2.1.15 (2019-10-14)

Note: Version bump only for package gatsby-plugin-typescript

2.1.14 (2019-10-14)

Note: Version bump only for package gatsby-plugin-typescript

2.1.13 (2019-10-14)

Note: Version bump only for package gatsby-plugin-typescript

2.1.12 (2019-10-09)

Note: Version bump only for package gatsby-plugin-typescript

2.1.11 (2019-09-26)

Note: Version bump only for package gatsby-plugin-typescript

2.1.10 (2019-09-26)

Note: Version bump only for package gatsby-plugin-typescript

2.1.9 (2019-09-20)

Note: Version bump only for package gatsby-plugin-typescript

2.1.8 (2019-09-16)

Bug Fixes

2.1.7 (2019-09-09)

Note: Version bump only for package gatsby-plugin-typescript

2.1.6 (2019-09-01)

Bug Fixes

  • update minor updates in packages except react, babel and eslint (#17254) (252d867)

2.1.5 (2019-08-23)

Note: Version bump only for package gatsby-plugin-typescript

2.1.4 (2019-08-22)

Note: Version bump only for package gatsby-plugin-typescript

2.1.3 (2019-08-20)

Note: Version bump only for package gatsby-plugin-typescript

2.1.2 (2019-07-12)

Bug Fixes

2.1.1 (2019-07-11)

Note: Version bump only for package gatsby-plugin-typescript

2.1.0 (2019-06-20)

Note: Version bump only for package gatsby-plugin-typescript

2.0.15 (2019-05-24)

Bug Fixes

2.0.14 (2019-05-16)

Note: Version bump only for package gatsby-plugin-typescript

2.0.13 (2019-04-23)

Note: Version bump only for package gatsby-plugin-typescript

2.0.12 (2019-04-02)

Note: Version bump only for package gatsby-plugin-typescript

2.0.11 (2019-03-11)

Note: Version bump only for package gatsby-plugin-typescript

2.0.10 (2019-03-04)

Note: Version bump only for package gatsby-plugin-typescript

2.0.9 (2019-02-22)

Note: Version bump only for package gatsby-plugin-typescript

2.0.8 (2019-02-13)

Note: Version bump only for package gatsby-plugin-typescript

2.0.7 (2019-02-04)

Note: Version bump only for package gatsby-plugin-typescript

2.0.6 (2019-02-01)

Note: Version bump only for package gatsby-plugin-typescript

2.0.5 (2019-02-01)

Note: Version bump only for package gatsby-plugin-typescript

2.0.4 (2019-01-28)

Note: Version bump only for package gatsby-plugin-typescript

2.0.3 (2018-12-05)

Features

  • gatsby-plugin-typescript: allow specifying babel preset options (#10248) (f106241)

2.0.2 (2018-11-29)

Note: Version bump only for package gatsby-plugin-typescript

2.0.1 (2018-10-29)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0 (2018-09-17)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-rc.6 (2018-09-13)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-rc.5 (2018-09-08)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-rc.4 (2018-09-05)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-rc.3 (2018-08-29)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-rc.2 (2018-08-29)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-rc.1 (2018-08-21)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-rc.0 (2018-08-21)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.10 (2018-08-20)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.9 (2018-07-31)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.8 (2018-07-31)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.7 (2018-07-21)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.6 (2018-07-18)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.5 (2018-07-02)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.4 (2018-06-21)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.3 (2018-06-21)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.2 (2018-06-20)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.1 (2018-06-17)

Note: Version bump only for package gatsby-plugin-typescript

2.0.0-beta.0 (2018-06-17)

Note: Version bump only for package gatsby-plugin-typescript