Skip to content

Add types for require.context  #1232

Description

@ProchaLu

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions