From a078a1b532f26c396e260e33a7c775c8c398e2f8 Mon Sep 17 00:00:00 2001 From: hasparus Date: Mon, 18 Jan 2021 13:05:35 +0100 Subject: [PATCH 1/3] fix(gatsby-plugin-typescript): add missing options validations --- .../src/__tests__/gatsby-node.js | 3 ++ .../src/gatsby-node.js | 19 +++++++++++ yarn.lock | 32 ------------------- 3 files changed, 22 insertions(+), 32 deletions(-) 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..dc14126dc6b7a 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.` + ) + .default(`React.Fragment`), 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.`) + .default(false), + allowDeclareFields: Joi.boolean() + .description( + `When enabled, type-only class fields are only removed if they are prefixed with the declare modifier.` + ) + .default(false), + 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.` + ) + .default(false), }) exports.resolvableExtensions = resolvableExtensions diff --git a/yarn.lock b/yarn.lock index 439a0bf6df9ce..360a44b4969a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5129,13 +5129,6 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" -ajax-request@^1.2.0: - version "1.2.3" - resolved "https://registry.yarnpkg.com/ajax-request/-/ajax-request-1.2.3.tgz#99fcbec1d6d2792f85fa949535332bd14f5f3790" - dependencies: - file-system "^2.1.1" - utils-extend "^1.0.7" - ajv-errors@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.0.tgz#ecf021fa108fd17dfb5e6b383f2dd233e31ffc59" @@ -6246,14 +6239,6 @@ base64-arraybuffer@0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" -base64-img@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/base64-img/-/base64-img-1.0.4.tgz#3e22d55d6c74a24553d840d2b1bc12a7db078d35" - integrity sha1-PiLVXWx0okVT2EDSsbwSp9sHjTU= - dependencies: - ajax-request "^1.2.0" - file-system "^2.1.0" - base64-js@^1.0.2, base64-js@^1.1.2, base64-js@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" @@ -11050,19 +11035,6 @@ file-loader@^1.1.11: loader-utils "^1.0.2" schema-utils "^0.4.5" -file-match@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/file-match/-/file-match-1.0.2.tgz#c9cad265d2c8adf3a81475b0df475859069faef7" - dependencies: - utils-extend "^1.0.6" - -file-system@^2.1.0, file-system@^2.1.1: - version "2.2.2" - resolved "https://registry.yarnpkg.com/file-system/-/file-system-2.2.2.tgz#7d65833e3a2347dcd956a813c677153ed3edd987" - dependencies: - file-match "^1.0.1" - utils-extend "^1.0.4" - file-type@5.2.0, file-type@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/file-type/-/file-type-5.2.0.tgz#2ddbea7c73ffe36368dfae49dc338c058c2b8ad6" @@ -25739,10 +25711,6 @@ utila@~0.4: version "0.4.0" resolved "https://registry.yarnpkg.com/utila/-/utila-0.4.0.tgz#8a16a05d445657a3aea5eecc5b12a4fa5379772c" -utils-extend@^1.0.4, utils-extend@^1.0.6, utils-extend@^1.0.7: - version "1.0.8" - resolved "https://registry.yarnpkg.com/utils-extend/-/utils-extend-1.0.8.tgz#ccfd7b64540f8e90ee21eec57769d0651cab8a5f" - utils-merge@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" From c83ed4781834f503763b90b8b2e9db7e6967d615 Mon Sep 17 00:00:00 2001 From: hasparus Date: Mon, 18 Jan 2021 14:32:01 +0100 Subject: [PATCH 2/3] test(gatsby-plugin-typescript): use defaults from @babel/preset-typescript instead of adding our own --- packages/gatsby-plugin-typescript/src/gatsby-node.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/gatsby-plugin-typescript/src/gatsby-node.js b/packages/gatsby-plugin-typescript/src/gatsby-node.js index dc14126dc6b7a..0ccfe8c41fe28 100644 --- a/packages/gatsby-plugin-typescript/src/gatsby-node.js +++ b/packages/gatsby-plugin-typescript/src/gatsby-node.js @@ -45,25 +45,25 @@ exports.pluginOptionsSchema = ({ Joi }) => .description( `Replace the function used when compiling JSX fragment expressions.` ) - .default(`React.Fragment`), + .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.`) - .default(false), + .optional(), allowDeclareFields: Joi.boolean() .description( `When enabled, type-only class fields are only removed if they are prefixed with the declare modifier.` ) - .default(false), + .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.` ) - .default(false), + .optional(), }) exports.resolvableExtensions = resolvableExtensions From bde7ca9e005d5453a063f43cb7a205be791259f5 Mon Sep 17 00:00:00 2001 From: hasparus Date: Mon, 18 Jan 2021 14:59:37 +0100 Subject: [PATCH 3/3] chore(gatsby-plugin-typescript): checkout yarn.lock from master --- yarn.lock | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/yarn.lock b/yarn.lock index 360a44b4969a0..439a0bf6df9ce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5129,6 +5129,13 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" +ajax-request@^1.2.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/ajax-request/-/ajax-request-1.2.3.tgz#99fcbec1d6d2792f85fa949535332bd14f5f3790" + dependencies: + file-system "^2.1.1" + utils-extend "^1.0.7" + ajv-errors@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.0.tgz#ecf021fa108fd17dfb5e6b383f2dd233e31ffc59" @@ -6239,6 +6246,14 @@ base64-arraybuffer@0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" +base64-img@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/base64-img/-/base64-img-1.0.4.tgz#3e22d55d6c74a24553d840d2b1bc12a7db078d35" + integrity sha1-PiLVXWx0okVT2EDSsbwSp9sHjTU= + dependencies: + ajax-request "^1.2.0" + file-system "^2.1.0" + base64-js@^1.0.2, base64-js@^1.1.2, base64-js@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" @@ -11035,6 +11050,19 @@ file-loader@^1.1.11: loader-utils "^1.0.2" schema-utils "^0.4.5" +file-match@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/file-match/-/file-match-1.0.2.tgz#c9cad265d2c8adf3a81475b0df475859069faef7" + dependencies: + utils-extend "^1.0.6" + +file-system@^2.1.0, file-system@^2.1.1: + version "2.2.2" + resolved "https://registry.yarnpkg.com/file-system/-/file-system-2.2.2.tgz#7d65833e3a2347dcd956a813c677153ed3edd987" + dependencies: + file-match "^1.0.1" + utils-extend "^1.0.4" + file-type@5.2.0, file-type@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/file-type/-/file-type-5.2.0.tgz#2ddbea7c73ffe36368dfae49dc338c058c2b8ad6" @@ -25711,6 +25739,10 @@ utila@~0.4: version "0.4.0" resolved "https://registry.yarnpkg.com/utila/-/utila-0.4.0.tgz#8a16a05d445657a3aea5eecc5b12a4fa5379772c" +utils-extend@^1.0.4, utils-extend@^1.0.6, utils-extend@^1.0.7: + version "1.0.8" + resolved "https://registry.yarnpkg.com/utils-extend/-/utils-extend-1.0.8.tgz#ccfd7b64540f8e90ee21eec57769d0651cab8a5f" + utils-merge@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"