[autodeps] Support namespaces - #32162
Merged
Merged
Conversation
jbrown215
marked this pull request as ready for review
January 22, 2025 22:36
mofeiZ
reviewed
Mar 3, 2025
| } else if ( | ||
| value.kind === 'PropertyLoad' && | ||
| typeof value.property === 'string' && | ||
| autodepModuleLoads.has(value.object.identifier.id) |
Contributor
There was a problem hiding this comment.
codestyle nit (feel free to take or leave it) -- I find it's easier to read long nested if-else chains if the outer / inner ifs are simple. e.g.
for (const instr of block.instructions) {
if (value.kind === "FunctionExpression") {
...
} else if (value.kind === "PropertyLoad") {
const moduleTarget = autodepModuleLoads.get(
value.object.identifier.id,
);
if (...) {
...
}
} else if (value.kind === "CallExpression" || value.kind === "MethodCall") {
...
}
}
Contributor
Author
There was a problem hiding this comment.
That's reasonable! I see why that would be easier to read
mofeiZ
reviewed
Mar 3, 2025
| @@ -1,9 +1,6 @@ | |||
| // @inferEffectDependencies | |||
| import * as React from 'react'; | |||
| import React from 'react'; | |||
Contributor
There was a problem hiding this comment.
Ahh makes sense, thanks for checking the ImportDefault case!
Summary: Summary: Correctly supports React.useEffect when React is imported as `import * as React from 'react'` (as well as other namespaces as specified in the config). Test Plan:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: Summary: Correctly supports React.useEffect when React is imported as
import * as React from 'react'(as well as other namespaces as specified in the config).
Test Plan:
Stack created with Sapling. Best reviewed with ReviewStack.