-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Type signature overload is ignored in a place where it makes better sense. #30343
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
Comments
@j-oliveras @DanielRosenwasser As you can see, I have seen and commented on that issue that you linked to this one as duplicate: |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Wait @typescript-bot why u do dis?! |
@RyanCavanaugh I believe your bot is malfunctioning, please help! |
@ackvf this is a question about how to get your JS file configured to see the global declaration file. I'd recommend StackOverflow as a good support point. Thanks! |
@RyanCavanaugh It does see the global declaration file as demonstrated in the gif, but it chose a different overload even though that overload results in an error. |
Overload resolution doesn't work by iterating each overload to see which makes your entire program not-an-error. The first matching overload is chosen; the return type isn't even part of this process. |
Call signature is already considered, but if two return types share one call signature, maybe it should also consider a return type and the surrounding? |
TypeScript Version: 3.4.0-dev.20190312
Search Terms:
ambient declaration overload
Preface:
I've been using these inline
console.debug(val) || val
statements for ages, but since recently,void
cannot be tested for truthiness. My workaround for typescript projects is to include this in mysrc/index.tsx
file, which works greatCode:
Expected behavior:
Expected is that the overload that returns false when used in place that test for truthiness is used.
When tested with
console.abc
, as per the interface, it is correctly picked up as returning false.Actual behavior:
error:
An expression of type 'void' cannot be tested for truthiness ts(1345)
Interestingly, after I have switched to ts@next and thus restarted the TS server, it first picks up my ambient declaration, so the code passes, but then it loads the
@types\node\globals.d.ts
The text was updated successfully, but these errors were encountered: