[Codegen] Improve assertGenericTypeAnnotationHasExactlyOneTypeParameter tests#34942
Conversation
| const flowTypeAnnotation = { | ||
| typeParameters: { | ||
| type: 'TypeParameterInstantiation', | ||
| type: 'wrongType', |
There was a problem hiding this comment.
This test case was ok because an Error was thrown even though the type had the correct value.
It was the fact that params was missing that caused an Error to be thrown.
cipolleschi
left a comment
There was a problem hiding this comment.
Hi @AntoineDoubovetzky, thanks a lot for this extra PR that shows how much you care. 🥰
Can you fix the linting error? It looks like there is an unused variable in the code!
Base commit: f353119 |
Base commit: f353119 |
|
@cipolleschi Sorry I didn't notice the unused import. I removed it! |
cipolleschi
left a comment
There was a problem hiding this comment.
Sorry, I missed this! It looks good!
|
@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 @AntoineDoubovetzky in 790f40c. When will my fix make it into a release? | Upcoming Releases |
Summary
#34933 has been merged just after I pushed a new commit to the branch to improve tests of
assertGenericTypeAnnotationHasExactlyOneTypeParameterfunction, but the last commit was not imported to the internal repository.The
assertGenericTypeAnnotationHasExactlyOneTypeParametercan throw different types of Error, and I believe that.toThrow(Error)is not specific enough. So I replaced it withtoThrowErrorMatchingInlineSnapshot().Changelog
[Internal] [Changed] - Improve assertGenericTypeAnnotationHasExactlyOneTypeParameter tests in parsers-commons
Test Plan
Some test cases were ok because the assertGenericTypeAnnotationHasExactlyOneTypeParameter function threw an Error, but for the wrong reason. I've made sure that the error displayed in the inline snapshot is the one we expect.