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 type Double = CodegenTypes.Double → resolves to Double → finds same alias → loops
digger deeper
parser : new RNFlowParser . FlowParser ( ) ,
isolates our case to the flow parser (not the ts one)
i.e. packages\react-native-codegen\src\parsers\flow\parser.js
it looks like getResolvedTypeAnnotation 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 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
i 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
Stacktrace or Logs
yarn validate:eslint --debug
MANDATORY Reproducer
appandflow/react-native-safe-area-context#744 (review)
Screenshots and Videos
No response
Description
For libs using ESLint plugin
@react-native/eslint-plugin-specsrule@react-native/specs/react-native-moduleswhen a type alias name matches the RHS, e.g.
ESLint never finishes (the Node process hangs)
a current workaround is to either use the namespace e.g.
CodegenTypes.Doubleeverywhereor rename your type alias to e.g.
type _Double = CodegenTypes.Doublefor nowe.g. appandflow/react-native-safe-area-context#744 (review)
seems like
type Double = CodegenTypes.Double→ resolves toDouble→ finds same alias → loopsdigger deeper
react-native/packages/eslint-plugin-specs/react-native-modules.js
Line 75 in 704c2b1
isolates our case to the flow parser (not the ts one)
i.e.
packages\react-native-codegen\src\parsers\flow\parser.jsit looks like
getResolvedTypeAnnotationis looping infinitely in theforloopso we need to break on circular type aliases
by monkey patching
node_modules\@react-native\codegen\lib\parsers\flow\parser.jsmanaged to get it working so 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
i also tested latest stable
Steps to reproduce
yarn validate:eslintReact Native Version
0.85.3, 0.87.0, main
Affected Platforms
Build - Linux, Build - Windows, Build - MacOS
Output of
npx @react-native-community/cli infoStacktrace or Logs
MANDATORY Reproducer
appandflow/react-native-safe-area-context#744 (review)
Screenshots and Videos
No response