-
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
Explicit undefined
return type checked similar to explicit void
return type
#53607
Conversation
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 39ed3b8. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at 39ed3b8. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 39ed3b8. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at 39ed3b8. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the diff-based top-repos suite on this PR at 39ed3b8. You can monitor the build here. Update: The results are in! |
@ahejlsberg Here are the results of running the user test suite comparing Unfortunately, something went wrong, but it probably wasn't caused by your change. |
@ahejlsberg Here they are:Comparison Report - main..53607
System
Hosts
Scenarios
Developer Information: |
@ahejlsberg Here are the results of running the top-repos suite comparing Everything looks good! |
Hey @ahejlsberg, the results of running the DT tests are ready. |
@typescript-bot pack this |
Hey @gabritto, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@typescript-bot perf test faster |
Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at 39ed3b8. You can monitor the build here. Update: The results are in! |
@ahejlsberg Here they are:Comparison Report - main..53607
System
Hosts
Scenarios
Developer Information: |
I reviewed, but let's just answer outstanding comments from @gabritto and others first. |
@typescript-bot user test this inline |
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at 39ed3b8. You can monitor the build here. Update: The results are in! |
@ahejlsberg Here are the results of running the user test suite comparing Unfortunately, something went wrong, but it probably wasn't caused by your change. |
I'm looking into what's going on with those tests. Not sure what's going wrong; it looks green but then decides to say that something failed. |
It looks like one of the user tests no longer npm installs correctly; not totally sure why we fail the whole thing due to that, though. Otherwise, reading the logs, this PR shows no change in any of those user tests. |
@gabritto Yeah, it would be more consistent for all of them to return the error. I will change the logic to have |
tests/baselines/reference/functionsMissingReturnStatementsAndExpressions.errors.txt
Show resolved
Hide resolved
} | ||
|
||
const f21: () => undefined | number = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these new cases, I would appreciate keeping the convention from the other tests of indicating if this will error :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can fix the comments.
In addition to addressing @gabritto's feedback, latest commits align the rules for |
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 40f9512. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at 40f9512. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 40f9512. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the diff-based top-repos suite on this PR at 40f9512. You can monitor the build here. Update: The results are in! |
@ahejlsberg Here are the results of running the user test suite comparing Unfortunately, something went wrong, but it probably wasn't caused by your change. |
Hey @ahejlsberg, the results of running the DT tests are ready. |
@ahejlsberg Here are the results of running the top-repos suite comparing Something interesting changed - please have a look. Details
|
A few new errors in |
Otherwise things look good, so I'm going to merge this. |
Sorry for replying to an old thread, but can I ask a question about this? Why is this not allowed for unions with function addListener(listener: (ev: Event) => undefined | boolean) {/*...*/}
addListener(ev => {/*... (no return)*/});
// Argument of type '(ev: Event) => void' is not assignable to parameter of type '(ev: Event) => boolean | undefined'.
// Type 'void' is not assignable to type 'boolean | undefined'. I think this could be a nice use case. |
This PR (hopefully) completes the work started in #53092 and subsequently modified in #53490. With this and the other PRs, checking of functions changes as follows compared to 5.0:
undefined
, expression-lessreturn
statements and the implicit return and the end of the function are considered to have typeundefined
(as opposed tovoid
). Note that this does not apply to functions with union return types that includeundefined
.undefined
aren't required to have return statements (similar to functions with an explicitly specified return type ofvoid
orany
). Note that this does not apply to functions with union return types that includeundefined
.--noImplicitReturns
option doesn't apply to functions with return types that includeundefined
(similar to functions with return types that includevoid
,any
, orunknown
).Fixes #36288.
Fixes #53473.