Skip to content

Commit

Permalink
Fix incorrectly set end locations for DeclareComponent and ComponentT…
Browse files Browse the repository at this point in the history
…ypeAnnotation

Summary:
The `DeclareComponent` and `ComponentTypeAnnotation` nodes were
incorrectly setting their end loc as `tok_->getEndLoc()` (the end of the
current token) instead of `getPrevTokenEndLoc()` (the end of the node).

Reviewed By: avp

Differential Revision: D45594191

fbshipit-source-id: 57ce7d54ab0cf5442a6d8813ccf230447feb109c
  • Loading branch information
pieterv authored and facebook-github-bot committed May 11, 2023
1 parent 636c8f8 commit ae61ae2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Parser/JSParserImpl-flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Optional<ESTree::Node *> JSParserImpl::parseComponentDeclarationFlow(

return setLocation(
start,
tok_->getEndLoc(),
getPrevTokenEndLoc(),
new (context_) ESTree::DeclareComponentNode(
*optId, std::move(paramList), rest, typeParams, returnType));
}
Expand Down Expand Up @@ -458,7 +458,7 @@ Optional<ESTree::Node *> JSParserImpl::parseComponentTypeAnnotationFlow() {

return setLocation(
start,
tok_->getEndLoc(),
getPrevTokenEndLoc(),
new (context_) ESTree::ComponentTypeAnnotationNode(
std::move(paramList), rest, typeParams, returnType));
}
Expand Down

0 comments on commit ae61ae2

Please sign in to comment.