From 0df146afb97b9af2fa9ce0a94577708cd0c67e98 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Sun, 2 Dec 2018 20:03:28 -0800 Subject: [PATCH 1/3] Pass through babel preset options --- packages/gatsby-plugin-typescript/src/gatsby-node.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-plugin-typescript/src/gatsby-node.js b/packages/gatsby-plugin-typescript/src/gatsby-node.js index 7ad59c0661ef1..7a1d7156443f7 100644 --- a/packages/gatsby-plugin-typescript/src/gatsby-node.js +++ b/packages/gatsby-plugin-typescript/src/gatsby-node.js @@ -1,8 +1,9 @@ const resolvableExtensions = () => [`.ts`, `.tsx`] -function onCreateBabelConfig({ actions }, pluginOptions) { +function onCreateBabelConfig({ actions }, options) { actions.setBabelPreset({ name: `@babel/preset-typescript`, + options, }) } From 858397558da2ba4b4a2c2adf9a35cef30ac8e915 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Mon, 3 Dec 2018 22:15:34 -0800 Subject: [PATCH 2/3] Add options section to gatsby-plugin-typescript docs --- packages/gatsby-plugin-typescript/README.md | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/gatsby-plugin-typescript/README.md b/packages/gatsby-plugin-typescript/README.md index 9e6354a9b5646..272fca996c35c 100644 --- a/packages/gatsby-plugin-typescript/README.md +++ b/packages/gatsby-plugin-typescript/README.md @@ -21,6 +21,28 @@ module.exports = { } ``` +## Options + +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. + +```javascript +// 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. + ## Caveats This plugin uses [`babel-plugin-transform-typescript`](https://babeljs.io/docs/en/babel-plugin-transform-typescript.html) From 38b5cddfa8301ffab84079ca4f24c5186c14ae55 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Tue, 4 Dec 2018 18:39:05 +0100 Subject: [PATCH 3/3] format --- packages/gatsby-plugin-typescript/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/gatsby-plugin-typescript/README.md b/packages/gatsby-plugin-typescript/README.md index 272fca996c35c..bc3f4b51aeb40 100644 --- a/packages/gatsby-plugin-typescript/README.md +++ b/packages/gatsby-plugin-typescript/README.md @@ -32,10 +32,10 @@ module.exports = { { resolve: `gatsby-plugin-typescript`, options: { - isTSX: true, // defaults to false - jsxPragma: `jsx`, // defaults to "React" + isTSX: true, // defaults to false + jsxPragma: `jsx`, // defaults to "React" allExtensions: true, // defaults to false - } + }, }, ], }