Repository navigation
docs: fix Flow spec examples that Codegen rejects in the Native Modules and Native Components guides - #5354
docs: fix Flow spec examples that Codegen rejects in the Native Modules and Native Components guides#5354Mosugar wants to merge 1 commit into
Conversation
…e and component guides Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SfhAdkfsSyVJ2HsRVtzmiC
|
Hi @Mosugar! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Requested by mosugar · project thread
Summary
The Flow tabs of two New Architecture guides have spec files that Codegen rejects, so readers who pick Flow and copy the example get an error before any native code runs.
Native Components (
fabric-native-components.md): theRCTWebViewNativeComponent.jsspec writes the optional handler asBubblingEventHandler<WebViewScriptLoadedEvent>?. A trailing?isn't valid Flow, so the file fails to parse:Fix: use Flow's maybe type,
?CodegenTypes.BubblingEventHandler<WebViewScriptLoadedEvent>. I also used,separators like the other Flow examples, changed the code fence fromtstoflow, and removed a stray:after thetitle.Native Modules (
turbo-native-modules.md): theNativeLocalStorage.jsspec importsTurboModuletwice, once as a type and once as a value (Identifier 'TurboModule' is already declared). It also never callsTurboModuleRegistry, so Codegen stops with:Fix: drop the duplicate value import and add the same
export default TurboModuleRegistry.getEnforcing<Spec>('NativeLocalStorage')that the TypeScript tab already has.I changed
docs/andwebsite/versioned_docs/version-0.88/so the fix shows on the current site.How I checked it
I extracted both Flow snippets before and after the change and ran them through
@react-native/codegen'sFlowParser.parseFile. The originals fail with the errors above. The fixed files parse and produce theCustomWebViewcomponent schema and theNativeLocalStoragemodule schema. Every other Flow block indocs/already parses withhermes-parser.🤖 Generated with Claude Code
https://claude.ai/code/session_01SfhAdkfsSyVJ2HsRVtzmiC