Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add types for `require.context`

Open
#1,232 1 comment 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale

Research direction

Start by reading the type declaration in the linked Metro-Context-Modules-Demo repository at types/metroRequire.d.ts, then locate Metro’s existing built-in type definitions. Add the require.context definitions so its arguments receive completion, error checking, and refactoring support. Done means the reported NodeRequire error is resolved for Metro users.

Written by the indexing model from the issue text.

Description

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.

Dominant language
JavaScript
Stars
5.6k
Forks
702
Avg merge
3d 2h
Merged PRs (30d)
44

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from react/metro

All issues in react/metro

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.