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

Add types for require.context #1232

Open
ProchaLu opened this issue Mar 8, 2024 · 1 comment
Open

Add types for require.context #1232

ProchaLu opened this issue Mar 8, 2024 · 1 comment

Comments

@ProchaLu
Copy link

ProchaLu commented Mar 8, 2024

Do you want to request a feature or report a bug?

Feature request

Currently, Metro supports require.context, added in this PR, but it lacks built-in type definitions. This makes it more challenging to use require.context effectively as there's no code completion, error checking, or refactoring support for its arguments.

Property 'context' does not exist on type 'NodeRequire'.
Screenshot 2024-03-08 at 15 17 28

Right now, I have to create a types file and add the following content from @EvanBacon's Metro-Context-Modules-Demo repo, having them included by default in Metro would be a great improvement.

Including type definitions for require.context would significantly improve the developer experience by enabling these features and making code using require.context more robust and maintainable.

@ProchaLu
Copy link
Author

ProchaLu commented Mar 8, 2024

Here's a related issue on the Facebook React Native repo

This PR discusses adding types for require.context. Do you believe it's still necessary to implement types for require.context separately, given the potential for including them directly in Metro?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant