New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update types for require
and require.context
#41421
base: main
Are you sure you want to change the base?
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 facebook/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 |
Summary:
It's been 1½ years since the merge of facebook/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.