Skip to content

Commit 3d22162

Browse files
authored
fixed bugs (#266)
1 parent c46e5f2 commit 3d22162

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import type React from "react";
2+
import * as React from "react";
3+
4+
<div>Hi</div>;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type React from "react";
2+
3+
<div>Hi</div>;

transforms/__tests__/update-react-imports-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const tests = [
1818
'react-basic-default-export-jsx-element-react-variable',
1919
'react-basic-default-export-jsx-element',
2020
'react-basic-default-export',
21+
'react-type-default-export',
2122
];
2223

2324
jest.mock('../update-react-imports', () => {

transforms/update-react-imports.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ module.exports = function(file, api, options) {
2727
.filter(path => {
2828
return (
2929
path.value.specifiers.length > 0 &&
30+
path.value.importKind === 'value' &&
3031
path.value.specifiers.some(
3132
specifier => specifier.local.name === 'React',
3233
)
3334
);
3435
});
3536

3637
if (reactImportPath.size() > 1) {
37-
throw Error('There should only be one React import. Please remove the duplicate import and try again.');
38+
throw Error(
39+
'There should only be one React import. Please remove the duplicate import and try again.',
40+
);
3841
}
3942

4043
if (reactImportPath.size() === 0) {
@@ -95,6 +98,9 @@ module.exports = function(file, api, options) {
9598
} else {
9699
j(reactPath).remove();
97100
}
101+
} else {
102+
// nothing is transformed so we can return
103+
return null;
98104
}
99105
}
100106
break;

0 commit comments

Comments
 (0)