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

Allow setting 'allowNamespaces' in typescript preset #10382

Merged
merged 2 commits into from Sep 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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