Skip to content

Improve error message for invalid continue target label#63413

Open
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:main
Open

Improve error message for invalid continue target label#63413
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:main

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 18, 2026

Good day

This PR improves the error message when a continue statement targets a label that is not a valid jump target.

Problem

When using continue labelName where labelName is defined after the loop (outside the loop's scope), TypeScript reports "Jump target cannot cross function boundary" which is confusing and doesn't clearly explain the actual issue.

Solution

Changed the error message to clearly indicate that a continue statement can only jump to labels on enclosing loop or switch statements.

Changes

  • Updated the diagnostic message for invalid continue/break label targets

Testing

Tested with the example from issue #30408 to confirm the improved error message.

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly,
RoomWithOutRoof

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Apr 18, 2026
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Apr 18, 2026
@typescript-bot
Copy link
Copy Markdown
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@Jah-yee Jah-yee closed this Apr 18, 2026
@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Apr 18, 2026
@Jah-yee Jah-yee reopened this Apr 18, 2026
@github-project-automation github-project-automation bot moved this from Done to Not started in PR Backlog Apr 18, 2026
@Jah-yee
Copy link
Copy Markdown
Author

Jah-yee commented Apr 18, 2026

Good day

Thank you for the feedback. This PR is related to issue #30408 - the improved error message addresses the confusing error reporting described in that issue.

The issue was filed as #30408 and this PR aims to improve the diagnostic message as suggested.

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly,
RoomWithOutRoof

@jakebailey
Copy link
Copy Markdown
Member

Please disclaim what tool you have used to send this PR

https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#use-of-ai-assistance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

3 participants