Skip to content

Commit bc47b87

Browse files
committed
Fix update-react-imports for TS
1 parent 75a061f commit bc47b87

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

transforms/update-react-imports.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ module.exports = function(file, api, options) {
4040
const reactImportPaths = root
4141
.find(j.ImportDeclaration, {
4242
type: 'ImportDeclaration',
43-
source: {
44-
type: 'Literal',
45-
},
4643
})
4744
.filter(path => {
4845
return (
49-
path.value.source.value === 'React' ||
50-
path.value.source.value === 'react'
46+
(
47+
path.value.source.type === 'Literal' ||
48+
path.value.source.type === 'StringLiteral'
49+
) && (
50+
path.value.source.value === 'React' ||
51+
path.value.source.value === 'react'
52+
)
5153
);
5254
});
5355

0 commit comments

Comments
 (0)