Update types for require and require.context#41421
Conversation
|
cc @EvanBacon What do you think? Is this ready for general consumption? |
93aa5cd to
3355ebc
Compare
It's been 1½ years since the merge of react/metro#822 and my hope is that this feature is ready to be documented and made available through types.
3355ebc to
3519dc9
Compare
|
I think we need to ship the feature as stable (and on by default) before we ship types that assume it's on. |
|
@motiz88 great point! I honestly don't know why I didn't realize this wasn't enabled by default. How about making the |
|
Unfortunately I don't think making it nullable is sufficient. We don't support feature-detecting |
Why wouldn't this work? if (require.context) {
require.context(/* ... */);
} |
|
Trying to verify this fix this today, I see that this change conflicts with the This is my experience in VSCode: |
|
Because of I hope to investigate other workarounds for this. |
|
Never mind, now I noticed there's runtime code throwing if we simply get
Even if we enable this by default, the types won't be accurate if users disable it - perhaps that's good enough? |
|
To be clear, at the point when we enable |
|
For anyone looking for a copy+paste |
|
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
I'm guessing this is not stale |
|
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
Not stale |
|
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
Not stale |

Summary:
It's been 1½ years since the merge of react/metro#822 and my hope is that this feature is ready to be documented and made available through types.
Changelog:
[GENERAL] [ADDED] - Added types for
require.context, which is provided by Metro at build time.Test Plan:
I've tested this manually in a project.