Don't error when function has an implicit return but its return type is assignable to undefined#53490
Merged
MariaSolOs merged 10 commits intomicrosoft:mainfrom Mar 27, 2023
Merged
Conversation
added 2 commits
March 24, 2023 12:41
jakebailey
reviewed
Mar 24, 2023
tests/cases/compiler/functionsWithImplicitReturnTypeAssignableToUndefined.ts
Outdated
Show resolved
Hide resolved
jakebailey
reviewed
Mar 24, 2023
.../baselines/reference/functionsWithImplicitReturnTypeAssignableToUndefinedStrictNullChecks.js
Outdated
Show resolved
Hide resolved
DanielRosenwasser
approved these changes
Mar 24, 2023
jakebailey
reviewed
Mar 27, 2023
jakebailey
reviewed
Mar 27, 2023
added 3 commits
March 27, 2023 12:20
This reverts commit 2f36455.
jakebailey
approved these changes
Mar 27, 2023
Member
|
I don't think this is the right fix for the issue. The following now doesn't error: function foo(x: boolean): string | undefined {
}This previously would report "A function whose declared type is neither 'void' nor 'any' must return a value." |
Member
|
The right fix is to put the assignability check back where it was originally. |
Member
|
Specifically, we need to undo the change I mention here. And then also undo the change in this PR. |
Contributor
Author
|
I'm confused with @jakebailey's comment. Is this a fix or a bug? 😄 |
Member
Is what a fix or a bug? |
Contributor
Author
@ahejlsberg Sorry I wasn't clear, I was referring to this PR. The way I read Jake's comment, this change fixes the issue you brought up here, but you're suggesting we undo it. |
Member
Contributor
Author
|
Got it, thanks for explaining! I can prepare that change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #53473