Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: codegen crash when parsing TS interfaces (#35492)
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: #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
- Loading branch information