mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Weak type errors for signature-only types too
Now source types that only have a call signature (like functions) or construct signature will get a weak type error too. This is really good for catching uncalled functions: ```ts functionTakingWeakType(returnWeakType); // OOPS. Forgot to call `returnWeakType()`. That's an error! ```
This commit is contained in:
parent
a453eff575
commit
a282cbb07e
@ -8938,7 +8938,9 @@ namespace ts {
|
||||
!(target.flags & TypeFlags.Union) &&
|
||||
!isIntersectionConstituent &&
|
||||
source !== globalObjectType &&
|
||||
getPropertiesOfType(source).length > 0 &&
|
||||
(getPropertiesOfType(source).length > 0 ||
|
||||
getSignaturesOfType(source, SignatureKind.Call).length > 0 ||
|
||||
getSignaturesOfType(source, SignatureKind.Construct).length > 0) &&
|
||||
isWeakType(target) &&
|
||||
!hasCommonProperties(source, target)) {
|
||||
if (reportErrors) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user