Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-plugin-typescript): add missing options validations #29066

Merged
merged 3 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ describe(`gatsby-plugin-typescript`, () => {
isTSX: false,
jsxPragma: `ReactFunction`,
hasparus marked this conversation as resolved.
Show resolved Hide resolved
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