Uh oh!
There was an error while loading. Please reload this page.
Don't error when function has an implicit return but its return type is assignable to undefined - #53490
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Anders Hejlsberg (ahejlsberg)
commented
Mar 28, 2023
I don't think this is the right fix for the issue. The following now doesn't error: functionfoo(x: boolean): string|undefined{}This previously would report "A function whose declared type is neither 'void' nor 'any' must return a value." |
Anders Hejlsberg (ahejlsberg)
commented
Mar 28, 2023
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. |
Maria Solano (MariaSolOs)
commented
Mar 28, 2023
I'm confused with Jake Bailey (@jakebailey)'s comment. Is this a fix or a bug? 😄 |
Anders Hejlsberg (ahejlsberg)
commented
Mar 28, 2023
Is what a fix or a bug? |
Maria Solano (MariaSolOs)
commented
Mar 28, 2023
Anders Hejlsberg (@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. |
Maria Solano (MariaSolOs)
commented
Mar 28, 2023
Got it, thanks for explaining! I can prepare that change. |
Fixes#53473