From c0e6c92570ab0dc935616933b71f9ac3bf1dd065 Mon Sep 17 00:00:00 2001 From: Piotr Monwid-Olechnowicz Date: Mon, 18 Jan 2021 16:06:07 +0100 Subject: [PATCH] fix(gatsby-plugin-typescript): add missing options validations (#29066) --- .../src/__tests__/gatsby-node.js | 3 +++ .../src/gatsby-node.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js b/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js index 1dce01b41caf1..989f0c17446f9 100644 --- a/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js +++ b/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js @@ -95,6 +95,9 @@ describe(`gatsby-plugin-typescript`, () => { isTSX: false, jsxPragma: `ReactFunction`, allExtensions: false, + allowNamespaces: false, + allowDeclareFields: false, + onlyRemoveTypeImports: false, }) expect(isValid).toBe(true) diff --git a/packages/gatsby-plugin-typescript/src/gatsby-node.js b/packages/gatsby-plugin-typescript/src/gatsby-node.js index 3c60f83a40363..0ccfe8c41fe28 100644 --- a/packages/gatsby-plugin-typescript/src/gatsby-node.js +++ b/packages/gatsby-plugin-typescript/src/gatsby-node.js @@ -41,10 +41,29 @@ exports.pluginOptionsSchema = ({ Joi }) => jsxPragma: Joi.string() .description(`Replace the function used when compiling JSX expressions.`) .default(`React`), + jsxPragmaFrag: Joi.string() + .description( + `Replace the function used when compiling JSX fragment expressions.` + ) + .optional(), allExtensions: Joi.boolean() .description(`Indicates that every file should be parsed as TS or TSX.`) .default(false) .when(`isTSX`, { is: true, then: Joi.valid(true) }), + allowNamespaces: Joi.boolean() + .description(`Enables compilation of TypeScript namespaces.`) + .optional(), + allowDeclareFields: Joi.boolean() + .description( + `When enabled, type-only class fields are only removed if they are prefixed with the declare modifier.` + ) + .optional(), + onlyRemoveTypeImports: Joi.boolean() + .description( + `When set to true, the transform will only remove type-only imports (introduced in TypeScript 3.8).` + + `This should only be used if you are using TypeScript >= 3.8.` + ) + .optional(), }) exports.resolvableExtensions = resolvableExtensions