Skip to content
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

Merged
merged 1 commit into from May 31, 2019

Conversation

Andarist
Copy link
Member

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

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.

@@ -39,16 +34,15 @@ export default declare((api, { jsxPragma = "React" }) => {
Identifier: visitPattern,
RestElement: visitPattern,

Program(path, state: State) {
state.programPath = path;
Copy link
Member Author

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];
Copy link
Member Author

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.

@existentialism existentialism added the PR: Polish 💅 A type of pull request used for our changelog categories label May 30, 2019
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10895/

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicolo-ribaudo nicolo-ribaudo merged commit 84961eb into babel:master May 31, 2019
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants