Extracted IncorrectModuleRegistryCallArityParserError as a seperate function in error-utils.js#34940
Conversation
…unction in error-utils.js
Base commit: f353119 |
cipolleschi
left a comment
There was a problem hiding this comment.
Amazing job, thank you for working on this.
I find that the name of the function is a bit obscure. How do you feel about the rename I'm suggesting in the PR?
| nativeModuleName: string, | ||
| flowCallExpression: $FlowFixMe, | ||
| methodName: string, | ||
| incorrectArity: number, |
There was a problem hiding this comment.
what about calling this numberOfCallExpressionArgs? I think that it conveys more semantic that just incorrectArity. Also, this is a parameter: it does not know there it is correct or not. It doesn't feel right to state incorrect in the parameter name. What do you think?
|
|
||
| const {IncorrectModuleRegistryCallArityParserError} = require('./errors'); | ||
|
|
||
| function throwIfIncorrectModuleRegistryCallArityParserError( |
There was a problem hiding this comment.
What about calling this function throwIfWrongNumberOfCallExpressionArgs? I think that it explains better what the method will do: if there is a wrong number of argument in the call expression, it throws.
What do you think?
| const {IncorrectModuleRegistryCallArityParserError} = require('../errors'); | ||
|
|
||
| describe('throwIfIncorrectModuleRegistryCallArityParserError', () => { | ||
| it('throw error if incorrect module registry call arity is used', () => { |
There was a problem hiding this comment.
we should update the it description if we change the name of the function.
Thanks for the review @cipolleschi, Changes suggested by you look good to me. |
Base commit: f353119 |
|
@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 @dakshbhardwaj in 76c5b6f. When will my fix make it into a release? | Upcoming Releases |
…unction in error-utils.js (facebook#34940) Summary: This PR is part of facebook#34872 This PR extracts `IncorrectModuleRegistryCallArityParserError` exception to `throwIfIncorrectModuleRegistryCallArityParserError` inside an `error-utils.js` file. [Internal] [Changed] - Extracted IncorrectModuleRegistryCallArityParserError exception to throwIfIncorrectModuleRegistryCallArityParserError function Pull Request resolved: facebook#34940 Test Plan: Added unit case in error-utils-test.js file yarn jest react-native-codegen <img width="1144" alt="Screenshot 2022-10-11 at 4 04 55 PM" src="https://user-images.githubusercontent.com/22423684/195070498-627d1bb8-53b1-43d3-b410-462e4f0da23a.png"> Reviewed By: dmytrorykun Differential Revision: D40296626 Pulled By: cipolleschi fbshipit-source-id: 33a299b1adf6334753c2390a81a54832c9096ec5
Summary
This PR is part of #34872
This PR extracts
IncorrectModuleRegistryCallArityParserErrorexception tothrowIfIncorrectModuleRegistryCallArityParserErrorinside anerror-utils.jsfile.Changelog
[Internal] [Changed] - Extracted IncorrectModuleRegistryCallArityParserError exception to throwIfIncorrectModuleRegistryCallArityParserError function
Test Plan
Added unit case in error-utils-test.js file
yarn jest react-native-codegen