mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
90871861ce
Summary:
when I'm defining a turbomodule spec, I tried to extract a common parameter into an interface.
The error I get is this:
```
[Codegen] >>>>> Processing RNSimpleToastSpec
[Codegen] Done.
/Users/vojta/_dev/_own/simple-toast/example/node_modules/react-native-codegen/lib/parsers/typescript/utils.js:111
throw error;
^
TypeError: Cannot read properties of undefined (reading 'length')
at isModuleInterface (/Users/vojta/_dev/_own/simple-toast/example/node_modules/react-native-codegen/lib/parsers/typescript/modules/index.js:695:18)
at Array.filter (<anonymous>)
at buildModuleSchema (/Users/vojta/_dev/_own/simple-toast/example/node_modules/react-native-codegen/lib/parsers/typescript/modules/index.js:709:44)
at /Users/vojta/_dev/_own/simple-toast/example/node_modules/react-native-codegen/lib/parsers/typescript/index.js:158:9
at guard (/Users/vojta/_dev/_own/simple-toast/example/node_modules/react-native-codegen/lib/parsers/typescript/utils.js:108:14)
at buildSchema (/Users/vojta/_dev/_own/simple-toast/example/node_modules/react-native-codegen/lib/parsers/typescript/index.js:157:22)
at Object.parseFile (/Users/vojta/_dev/_own/simple-toast/example/node_modules/react-native-codegen/lib/parsers/typescript/index.js:185:10)
```
After the fix I get this:
```
[Codegen] >>>>> Processing RNSimpleToastSpec
[Codegen] Done.
/Users/vojta/_dev/_own/simple-toast/example/node_modules/react-native-codegen/lib/parsers/typescript/utils.js:111
throw error;
^
Invariant Violation: GenericTypeAnnotation 'Styles' must resolve to a TSTypeAliasDeclaration. Instead, it resolved to a 'TSInterfaceDeclaration'
```
Then I know that I should not be using an `interface` but a `type`
## Changelog
[Internal] [Fixed] - TS codegen crash when parsing interfaces
Pull Request resolved: https://github.com/facebook/react-native/pull/35492
Test Plan:
tested locally
let me know if you want an automated test
Reviewed By: cortinico
Differential Revision: D41548015
Pulled By: cipolleschi
fbshipit-source-id: 9acf02dffbb084831690f665357fb80225cbce0d
react-native-codegen
Installation
yarn add --dev react-native-codegen
Note: We're using yarn to install deps. Feel free to change commands to use npm 3+ and npx if you like
Testing
To run the tests in this package, run the following commands from the react Native root folder:
yarnto install the dependencies. You just need to run this onceyarn jest react-native-codegen.