Skip to content

Commit

Permalink
Allow setting 'allowNamespaces' in typescript preset (#10382)
Browse files Browse the repository at this point in the history
* Support 'allowNamespaces' in typescript preset

* Remove default for allowNamespaces
  • Loading branch information
dsgkirkby authored and JLHwung committed Sep 3, 2019
1 parent e7fa566 commit e5afa57
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/babel-preset-typescript/src/index.js
Expand Up @@ -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") {
Expand All @@ -20,21 +23,28 @@ export default declare(
overrides: allExtensions
? [
{
plugins: [[transformTypeScript, { jsxPragma, isTSX }]],
plugins: [
[transformTypeScript, { jsxPragma, isTSX, allowNamespaces }],
],
},
]
: [
{
// 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 },
],
],
},
],
};
Expand Down

0 comments on commit e5afa57

Please sign in to comment.