[Codegen]: Extract module/errors into a shared file#34896
Conversation
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Base commit: fa22a6e |
Base commit: fa22a6e |
|
/rebase |
beb5481 to
6523b87
Compare
|
This PR should depend on this: #34874. |
|
We merged #34874 earlier today! :D |
49765f3 to
563f0aa
Compare
Sure. |
563f0aa to
8958a1e
Compare
cipolleschi
left a comment
There was a problem hiding this comment.
Thank you so much for this work! :D
This will enable further improvements!
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
In #34916, another contributor suggested to use a union type to describe the parsers. I really like this suggestion, and Flow will help users typing the errors if we type this correctly.
Ideally, we can do something like:
type ParserType = 'Flow' | 'TypeScript'
// ...
// update all the constructors
class MisnamedModuleInterfaceParserError extends ParserError {
constructor(nativeModuleName: string, id: $FlowFixMe, language: ParserType) {
// ...Nothing else in the logic will change, but the types will be more precise.
What do you think? Could you please update the PR? 🙏
There was a problem hiding this comment.
I agree. I'll update the PR
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
/rebase |
7a4dbfd to
1e3b195
Compare
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
This pull request was successfully merged by @tarunrajput in 7b345bc. When will my fix make it into a release? | Upcoming Releases |
Summary
This PR reduces code duplication by extracting all the errors in the module/errors into a single parsers/errors.js file. All the errors must drop the corresponding Flow or Typescript token in the name and take an extra language parameter in the constructor. Also, rename the hasteModuleName parameter to nativeModuleName.
Part of #34872
Changelog
[Internal] [Changed] - Extract all the parsers errors in the module/errors into a single parsers/errors.js file
Test Plan
run
yarn jest react-native-codegenand check all test case passes.