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
Refactor isImportTypeOnly helper function #10047
Refactor isImportTypeOnly helper function #10047
Conversation
@@ -39,16 +34,15 @@ export default declare((api, { jsxPragma = "React" }) => { | |||
Identifier: visitPattern, | |||
RestElement: visitPattern, | |||
|
|||
Program(path, state: State) { | |||
state.programPath = path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was some leftover, not used anymore
|
||
if (file.ast.comments) { | ||
for (const comment of (file.ast.comments: Array<Object>)) { | ||
const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value); | ||
if (jsxMatches) { | ||
file.set(PRAGMA_KEY, jsxMatches[1]); | ||
fileJsxPragma = jsxMatches[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of storing this in a shared mutable state under some artificial key I think it's better to just pass it as explicit argument to isImportTypeOnly
, as it makes the data flow clearer - especially that this info doesn't have to be passed through layers of functions, it's needed just one 1 level lower.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10895/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I've bumped onto the issue fixed by this because I had outdated dependencies, was reading the code and noticed those few small things that could be improved so I've prepared this small PR.