Fix check for type imports in transform-react-native-svg #907
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I was trying to use the babel-plugin-transform-react-native-svg separately in babel without svgr and hit an issue where it wouldn't update the import declaration.
I managed to pin it down to the new check added in #894. As per the babel spec for imports,
importKind
will benull | 'type' | 'typeof' | 'value'
. When using babel to parse an existing import, its being parsed as'value'
...I think its
null
when working with svgr because when we add the import declaration to the AST, we don't specify the import kind parameter when callinggetOrCreateImport
.Test plan
Add a new test to
index.test.ts
forbabel-plugin-transform-react-native-svg
:Before my changes:
After my changes: