Skip to content

Conversation

@josephsavona
Copy link
Member

When a longer function or expression is identified as the source of an error, we currently print the entire expression in our error message. This is because we delegate to a Babel helper to print codeframes. Here, we add some checking and abbreviate the result if it spans too many lines.

@meta-cla meta-cla bot added the CLA Signed label Oct 23, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Oct 23, 2025
0,
CODEFRAME_LINES_ABOVE + CODEFRAME_ABBREVIATED_SOURCE_LINES,
),
'> ' + ' '.repeat(pipeIndex - 2) + '…',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we add the pipe index here?

Currently we have

   2 | function Component(props) {
>  3 |   const data = useMemo(() => {
     |                        ^^^^^^^
>    …
>  7 |   }, [props.items?.edges?.nodes]);
     | ^^^^ Could not preserve existing manual memoization

Would it look better as this?

   2 | function Component(props) {
>  3 |   const data = useMemo(() => {
     |                        ^^^^^^^
>    | …
>  7 |   }, [props.items?.edges?.nodes]);
     | ^^^^ Could not preserve existing manual memoization

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally did that, but it looks weird since the ellipsis isn't indented propery. I like the ellipsis in place of the pipe to show it's not continuous. 🤷‍♂️

0,
CODEFRAME_LINES_ABOVE + CODEFRAME_ABBREVIATED_SOURCE_LINES,
),
'> ' + ' '.repeat(pipeIndex - 2) + '…',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'> ' + ' '.repeat(pipeIndex - 2) + '…',
'> ' + ' '.repeat(pipeIndex - 2) + '| …',

When a longer function or expression is identified as the source of an error, we currently print the entire expression in our error message. This is because we delegate to a Babel helper to print codeframes. Here, we add some checking and abbreviate the result if it spans too many lines.
@josephsavona
Copy link
Member Author

Closes #34795

@josephsavona josephsavona merged commit 408b38e into main Oct 23, 2025
19 of 20 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 23, 2025
When a longer function or expression is identified as the source of an
error, we currently print the entire expression in our error message.
This is because we delegate to a Babel helper to print codeframes. Here,
we add some checking and abbreviate the result if it spans too many
lines.

DiffTrain build for [408b38e](408b38e)
github-actions bot pushed a commit that referenced this pull request Oct 23, 2025
When a longer function or expression is identified as the source of an
error, we currently print the entire expression in our error message.
This is because we delegate to a Babel helper to print codeframes. Here,
we add some checking and abbreviate the result if it spans too many
lines.

DiffTrain build for [408b38e](408b38e)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Oct 26, 2025
…ook#34963)

When a longer function or expression is identified as the source of an
error, we currently print the entire expression in our error message.
This is because we delegate to a Babel helper to print codeframes. Here,
we add some checking and abbreviate the result if it spans too many
lines.

DiffTrain build for [408b38e](facebook@408b38e)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Oct 26, 2025
…ook#34963)

When a longer function or expression is identified as the source of an
error, we currently print the entire expression in our error message.
This is because we delegate to a Babel helper to print codeframes. Here,
we add some checking and abbreviate the result if it spans too many
lines.

DiffTrain build for [408b38e](facebook@408b38e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants