Skip to content

Commit f106241

Browse files
colebemispieh
authored andcommitted
feat(gatsby-plugin-typescript): allow specifying babel preset options (#10248)
* Pass through babel preset options * Add options section to gatsby-plugin-typescript docs * format
1 parent f95a9d7 commit f106241

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

packages/gatsby-plugin-typescript/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@ module.exports = {
2121
}
2222
```
2323

24+
## Options
25+
26+
When adding this plugin to your `gatsby-config.js`, you can pass in options to override the default [@babel/preset-typescript](https://babeljs.io/docs/en/babel-preset-typescript#options) config.
27+
28+
```javascript
29+
// gatsby-config.js
30+
module.exports = {
31+
plugins: [
32+
{
33+
resolve: `gatsby-plugin-typescript`,
34+
options: {
35+
isTSX: true, // defaults to false
36+
jsxPragma: `jsx`, // defaults to "React"
37+
allExtensions: true, // defaults to false
38+
},
39+
},
40+
],
41+
}
42+
```
43+
44+
For more detailed documentation on the available options, visit https://babeljs.io/docs/en/babel-preset-typescript#options.
45+
2446
## Caveats
2547

2648
This plugin uses [`babel-plugin-transform-typescript`](https://babeljs.io/docs/en/babel-plugin-transform-typescript.html)

packages/gatsby-plugin-typescript/src/gatsby-node.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const resolvableExtensions = () => [`.ts`, `.tsx`]
22

3-
function onCreateBabelConfig({ actions }, pluginOptions) {
3+
function onCreateBabelConfig({ actions }, options) {
44
actions.setBabelPreset({
55
name: `@babel/preset-typescript`,
6+
options,
67
})
78
}
89

0 commit comments

Comments
 (0)