Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: specify gatsby versions supporting particular TS features #34945

Merged
merged 2 commits into from
Feb 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/docs/how-to/custom-configuration/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export const query = graphql`

### `gatsby-browser.tsx` / `gatsby-ssr.tsx`

> Support added in `[email protected]`

You can also write `gatsby-browser` and `gatsby-ssr` in TypeScript. You have the types `GatsbyBrowser` and `GatsbySSR` available to type your API functions. Here are two examples:

```tsx:title=gatsby-browser.tsx
Expand Down Expand Up @@ -155,6 +157,8 @@ const getServerData: GetServerData<ServerDataProps> = async props => {

### `gatsby-config.ts`

> Support added in `[email protected]`

You can import the type `GatsbyConfig` to type your config object. **Please note:** There are currently no type hints for `plugins` and you'll need to check the [current limitations](#current-limitations) and see if they apply to your `gatsby-config` file.

```ts:title=gatsby-config.ts
Expand All @@ -172,6 +176,8 @@ export default config

### `gatsby-node.ts`

> Support added in `[email protected]`

You can import the type `GatsbyNode` to type your APIs by accessing keys on `GatsbyNode`, e.g. `GatsbyNode["sourceNodes"]`. **Please note:** You'll need to check the [current limitations](#current-limitations) and see if they apply to your `gatsby-node` file.

```ts:title=gatsby-node.ts
Expand Down Expand Up @@ -211,6 +217,8 @@ export const sourceNodes: GatsbyNode["sourceNodes"] = async ({

### Local Plugins

> Support added in `[email protected]`

All the files mentioned above can also be written and used inside a [local plugin](/docs/creating-a-local-plugin/).

## `tsconfig.json`
Expand Down