Skip to content

Commit

Permalink
fix(gatsby-plugin-typescript): add missing options validations (#29066)
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus authored Jan 18, 2021
1 parent 3163ca6 commit c0e6c92
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ describe(`gatsby-plugin-typescript`, () => {
isTSX: false,
jsxPragma: `ReactFunction`,
allExtensions: false,
allowNamespaces: false,
allowDeclareFields: false,
onlyRemoveTypeImports: false,
})

expect(isValid).toBe(true)
Expand Down
19 changes: 19 additions & 0 deletions packages/gatsby-plugin-typescript/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c0e6c92

Please sign in to comment.