Add types for `require.context`
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
- Tech stack
- javascript, typescript
- Domain
- developer-experience, tooling
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'.
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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from react/metro
-
constant-folding-plugin emits 0/0 (NaN) for arithmetic on destructured bindingsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react/metro#1927 · 1 comment ·
Maintainers usually reply within 1 day
-
[0.83.x] Backport micromatch removal and dotfile/multipart watcher fix togetherPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
`dependencies is not iterable` / `Cannot read property 'reduce' of undefined`: `FileStore` serves zero-prefixed cache files as hitsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
react/metro#1961 · 1 comment ·
Maintainers usually reply within 1 day
-
Async chunk URLs drop the file extension, so .cjs async imports fail with "Requiring unknown module"Possibly taken @dasjideepak claimed this 11 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 74/100
react/metro#1959 · 2 comments · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
Similar issues
-
[Bug] Composer can submit an IME confirmation when keyCode is 229 but isComposing is falsePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/rocketmq-dashboard#6067 ·
Maintainers usually reply within 4 days
-
severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
luainkernel/lunatik#1853 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
factory-active factory-automatic harness/claude-code task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day