Add types for `require.context`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
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'.
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- javascript, typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100