Skip to content

Commit 2a32c30

Browse files
davwheatLekoArts
andauthored
chore(docs): Add note about TS limitations on MDX layout components (#38104)
Co-authored-by: Lennart <[email protected]>
1 parent 0ca811b commit 2a32c30

File tree

1 file changed

+8
-0
lines changed
  • docs/docs/how-to/routing

1 file changed

+8
-0
lines changed

docs/docs/how-to/routing/mdx.md

+8
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,14 @@ Now you need to tell `gatsby-plugin-mdx` to use your `PageTemplate` component as
389389

390390
From an absolute path to your component (e.g. `/absolute/path/to/layout-component.js`) to a path that contains a query parameter `__contentFilePath` (e.g. `/absolute/path/to/layout-component.js?__contentFilePath=/absolute/path/to/content.mdx`).
391391

392+
<Announcement>
393+
394+
**Please note:** While you can create your layout templates as [TypeScript files](/docs/how-to/custom-configuration/typescript/) (e.g. `post.tsx`) you can't actually use most TypeScript syntax. This is because the underlying [acorn](https://github.com/acornjs/acorn/tree/master/acorn/) parser only understands modern JS and JSX syntax.
395+
396+
However, you can import your TypeScript types from another file instead. In most cases this should then work — if you're still encountering an "Unexpected token" error, try removing TypeScript syntax piece by piece to see why it breaks.
397+
398+
</Announcement>
399+
392400
Change your `gatsby-node.js` as following:
393401

394402
```diff

0 commit comments

Comments
 (0)