Skip to content

Commit

Permalink
fix: don't elide jsx pragma import namespaces (#11523)
Browse files Browse the repository at this point in the history
* fix: don't elide jsx pragma import namespaces

* use the correct pragma oops
  • Loading branch information
jquense committed May 14, 2020
1 parent 9a52019 commit de8264c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/babel-plugin-transform-typescript/src/index.js
Expand Up @@ -169,6 +169,11 @@ export default declare(
}
}

let pragmaImportName = fileJsxPragma || jsxPragma;
if (pragmaImportName) {
[pragmaImportName] = pragmaImportName.split(".");
}

// remove type imports
for (let stmt of path.get("body")) {
if (t.isImportDeclaration(stmt)) {
Expand Down Expand Up @@ -203,7 +208,7 @@ export default declare(
isImportTypeOnly({
binding,
programPath: path,
jsxPragma: fileJsxPragma || jsxPragma,
jsxPragma: pragmaImportName,
})
) {
importsToRemove.push(binding.path);
Expand Down
@@ -0,0 +1,4 @@
/* @jsx jsx.htm */
// Don't elide htm if a JSX element appears somewhere.
import * as jsx from "fake-jsx-package";
<div></div>;
@@ -0,0 +1,3 @@
{
"plugins": [["transform-typescript", { "isTSX": true }]]
}
@@ -0,0 +1,4 @@
/* @jsx jsx.htm */
// Don't elide htm if a JSX element appears somewhere.
import * as jsx from "fake-jsx-package";
<div></div>;

0 comments on commit de8264c

Please sign in to comment.