Codegen flow and typescript parsers infinite loop caused by circular aliases #57956
Description
Description
For libs using ESLint plugin @react-native/eslint-plugin-specs rule @react-native/specs/react-native-modules
when a type alias name matches the RHS, e.g.
import { TurboModule, TurboModuleRegistry } from 'react-native';
import type { CodegenTypes } from 'react-native';
type Double = CodegenTypes.Double; // 👀ESLint never finishes (the Node process hangs)
a current workaround is to either use the namespace e.g. CodegenTypes.Double everywhere
or rename your type alias to e.g. type _Double = CodegenTypes.Double for now
e.g. appandflow/react-native-safe-area-context#744 (review)
seems like the AST is being parsed like
type Double = CodegenTypes.Double → resolves to Double (same GenericTypeAnnotation TypeAlias) → repeat
digging deeper
| only: [/react-native-codegen\/src\//], |
| parser: new RNFlowParser.FlowParser(), |
isolates this to codegen flow parser (not the ts one)
i.e. packages\react-native-codegen\src\parsers\flow\parser.js
it looks like getResolvedTypeAnnotation (called indirectly in RNFlowParser/RNModuleParser/RNParserCommons)
is looping infinitely in the for loop so we need to break on circular type aliases
by monkey patching node_modules\@react-native\codegen\lib\parsers\flow\parser.js
managed to get it working so can propose a fix for the flow parser
it looks like it also happens with the ts parser, so can follow-up with a similar (if not the same) fix there too
also tested latest stable
"resolutions": {
"@react-native/codegen": "0.87.0"
},Steps to reproduce
- fix: replace deep RN imports with public API appandflow/react-native-safe-area-context#744 (review)
yarn validate:eslint
React Native Version
0.85.3, 0.87.0, main
Affected Platforms
Build - Linux, Build - Windows, Build - MacOS
Output of npx @react-native-community/cli info
N/A
Stacktrace or Logs
yarn validate:eslint --debugMANDATORY Reproducer
appandflow/react-native-safe-area-context#744 (review)
Screenshots and Videos
No response
Activity
react-native-bot commentedon Aug 13, 2026
Warning
Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:
You can read more about about it on our website: How to report a bug.
fix: replace deep RN imports with public API
fix: replace deep RN imports with public API
fix(codegen): infinite loop on type aliases that shadow CodegenTypes …
fix(codegen): infinite loop on type aliases that shadow CodegenTypes …
fix(codegen): infinite loop on type aliases that shadow CodegenTypes …