diff --git a/packages/babel-plugin-transform-typescript/src/index.js b/packages/babel-plugin-transform-typescript/src/index.js index 6e685b9f69..9ba2e23d89 100644 --- a/packages/babel-plugin-transform-typescript/src/index.js +++ b/packages/babel-plugin-transform-typescript/src/index.js @@ -291,6 +291,9 @@ export default declare((api, { jsxPragma = "React" }) => { JSXElement() { sourceFileHasJsx = true; }, + JSXFragment() { + sourceFileHasJsx = true; + }, }); return !sourceFileHasJsx; } diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react-no-3/input.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react-no-3/input.mjs new file mode 100644 index 0000000000..f9ae2b0323 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react-no-3/input.mjs @@ -0,0 +1,3 @@ +// Don't elide React if a JSX fragment appears somewhere. +import * as React from "react"; +<>; diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react-no-3/options.json b/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react-no-3/options.json new file mode 100644 index 0000000000..2552742a15 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react-no-3/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["syntax-jsx", "transform-typescript"] +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react-no-3/output.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react-no-3/output.mjs new file mode 100644 index 0000000000..f9ae2b0323 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/elide-react-no-3/output.mjs @@ -0,0 +1,3 @@ +// Don't elide React if a JSX fragment appears somewhere. +import * as React from "react"; +<>;