From e5afa57ccad38ab961cfdc9a1886509916537e4c Mon Sep 17 00:00:00 2001 From: Dylan Kirkby Date: Mon, 2 Sep 2019 17:33:01 -0700 Subject: [PATCH] Allow setting 'allowNamespaces' in typescript preset (#10382) * Support 'allowNamespaces' in typescript preset * Remove default for allowNamespaces --- packages/babel-preset-typescript/src/index.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/babel-preset-typescript/src/index.js b/packages/babel-preset-typescript/src/index.js index ebbb2390fd..bb1687e623 100644 --- a/packages/babel-preset-typescript/src/index.js +++ b/packages/babel-preset-typescript/src/index.js @@ -2,7 +2,10 @@ import { declare } from "@babel/helper-plugin-utils"; import transformTypeScript from "@babel/plugin-transform-typescript"; export default declare( - (api, { jsxPragma, allExtensions = false, isTSX = false }) => { + ( + api, + { jsxPragma, allExtensions = false, isTSX = false, allowNamespaces }, + ) => { api.assertVersion(7); if (typeof allExtensions !== "boolean") { @@ -20,7 +23,9 @@ export default declare( overrides: allExtensions ? [ { - plugins: [[transformTypeScript, { jsxPragma, isTSX }]], + plugins: [ + [transformTypeScript, { jsxPragma, isTSX, allowNamespaces }], + ], }, ] : [ @@ -28,13 +33,18 @@ export default declare( // Only set 'test' if explicitly requested, since it requires that // Babel is being called` test: /\.ts$/, - plugins: [[transformTypeScript, { jsxPragma }]], + plugins: [[transformTypeScript, { jsxPragma, allowNamespaces }]], }, { // Only set 'test' if explicitly requested, since it requires that // Babel is being called` test: /\.tsx$/, - plugins: [[transformTypeScript, { jsxPragma, isTSX: true }]], + plugins: [ + [ + transformTypeScript, + { jsxPragma, isTSX: true, allowNamespaces }, + ], + ], }, ], };