Skip to content

Don't mention all the possible return types that permit no return statements #53560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

DanielRosenwasser
Copy link
Member

Fixes #53559.

@@ -3619,7 +3615,7 @@
"category": "Error",
"code": 2846
},
"A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.": {
"A function with this return type needs to explicitly return a value.": {
Copy link
Member

Choose a reason for hiding this comment

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

"must explicitly"? (Not sure what form we use most often)

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's pretend we're starting from scratch. What would you prefer to see as a user?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this diagnostic, but I might be a bit confused when the return type is inferred. That's unrelated to the message per se though.

Copy link
Member

Choose a reason for hiding this comment

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

Can we do something like A function with return type 'X' needs to explicitly return a value.? I think this would help with Maria's point about when the return type is inferred.

@MariaSolOs
Copy link
Contributor

@DanielRosenwasser FYI #53561

@gabritto
Copy link
Member

Do we still want to merge this?

@DanielRosenwasser DanielRosenwasser deleted the accurateImplicitReturnErrors branch September 24, 2024 18:54
@sandersn sandersn removed this from PR Backlog Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error for explicit return type with no return statements is misleading
5 participants