-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't error when function has an implicit return but its return type is assignable to undefined
#53490
Don't error when function has an implicit return but its return type is assignable to undefined
#53490
Conversation
tests/cases/compiler/functionsWithImplicitReturnTypeAssignableToUndefined.ts
Outdated
Show resolved
Hide resolved
.../baselines/reference/functionsWithImplicitReturnTypeAssignableToUndefinedStrictNullChecks.js
Outdated
Show resolved
Hide resolved
This reverts commit 2f36455.
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." |
The right fix is to put the assignability check back where it was originally. |
Specifically, we need to undo the change I mention here. And then also undo the change in this PR. |
I'm confused with @jakebailey's comment. Is this a fix or a bug? 😄 |
Is what a fix or a bug? |
@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. |
Got it, thanks for explaining! I can prepare that change. |
Fixes #53473