-
-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change SVGProps
from import to import type
#853
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks @johncch, I know it is not what you are fixing, but tests are actually broken. Could you please try to fix it? Else I will give a look when I have a moment. |
Hi @gregberge, this is what I found: The build is failing because it is not able to find the type definition file for svgr/core: This only happens on a clean build. On the second build, since the dist folder already exists, it will just use the one that is built in the previous run. I replicated it and verified it by running this command in the CLI to delete all the dist folders before rebuilding it.
I can fix it locally and verified that the error stops occurring by adding I'm assuming that your intention is to not have the
If you feel good about this I'll add a commit to this PR. |
Hello @johncch, could you rebase, with |
…g is present Accomplished this by adding `importKind` parameter to the `getOrCreateImport` method
Ok - rebased. I think it should be good. The tests run locally for me. |
Codecov Report
@@ Coverage Diff @@
## main #853 +/- ##
==========================================
+ Coverage 92.82% 92.87% +0.04%
==========================================
Files 32 32
Lines 753 758 +5
Branches 250 253 +3
==========================================
+ Hits 699 704 +5
Misses 53 53
Partials 1 1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Summary
This PR changes
SVGProp
from value import to type import when the--typescript
flag is supplied.Here's an example of the change:
The change is quite straightforward. It adds a
importKind
parameter to thegetOrCreateImport
method so that both when importing the react and react-native versions ofSVGProps
, we can create theImportDeclaration
node with the rightimportKind
parameter.This addresses the warning for
verbatimModuleSyntax
flag in Typescript 5.0, seen below[they shipped the --verbatimModuleSyntax flag]Note: this PR is branched off f20a753 because the build was failing in the newer commits.
This PR addresses #842
Test plan
I ran the jest tests and inspected the generated output to make sure they are correct.
I ran the updated script against my folder of SVGs and the Typescript compiler was happy with them.