Never-reducing intersections are not untyped function call targets (#42917)
* Never-reducing intersections are not untyped function call targets * Don’t attempt to reduce union types
This commit is contained in:
parent
8d58c8d90b
commit
56cf2e68e8
|
@ -28474,7 +28474,7 @@ namespace ts {
|
|||
function isUntypedFunctionCall(funcType: Type, apparentFuncType: Type, numCallSignatures: number, numConstructSignatures: number): boolean {
|
||||
// We exclude union types because we may have a union of function types that happen to have no common signatures.
|
||||
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & TypeFlags.TypeParameter) ||
|
||||
!numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (TypeFlags.Union | TypeFlags.Never)) && isTypeAssignableTo(funcType, globalFunctionType);
|
||||
!numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & TypeFlags.Union) && !(getReducedType(apparentFuncType).flags & TypeFlags.Never) && isTypeAssignableTo(funcType, globalFunctionType);
|
||||
}
|
||||
|
||||
function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[] | undefined, checkMode: CheckMode): Signature {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
tests/cases/conformance/types/never/neverIntersectionNotCallable.ts(2,1): error TS2349: This expression is not callable.
|
||||
Type 'never' has no call signatures.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/never/neverIntersectionNotCallable.ts (1 errors) ====
|
||||
declare const f: { (x: string): number, a: "" } & { a: number }
|
||||
f()
|
||||
~
|
||||
!!! error TS2349: This expression is not callable.
|
||||
!!! error TS2349: Type 'never' has no call signatures.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
//// [neverIntersectionNotCallable.ts]
|
||||
declare const f: { (x: string): number, a: "" } & { a: number }
|
||||
f()
|
||||
|
||||
|
||||
//// [neverIntersectionNotCallable.js]
|
||||
f();
|
|
@ -0,0 +1,10 @@
|
|||
=== tests/cases/conformance/types/never/neverIntersectionNotCallable.ts ===
|
||||
declare const f: { (x: string): number, a: "" } & { a: number }
|
||||
>f : Symbol(f, Decl(neverIntersectionNotCallable.ts, 0, 13))
|
||||
>x : Symbol(x, Decl(neverIntersectionNotCallable.ts, 0, 20))
|
||||
>a : Symbol(a, Decl(neverIntersectionNotCallable.ts, 0, 39))
|
||||
>a : Symbol(a, Decl(neverIntersectionNotCallable.ts, 0, 51))
|
||||
|
||||
f()
|
||||
>f : Symbol(f, Decl(neverIntersectionNotCallable.ts, 0, 13))
|
||||
|
11
tests/baselines/reference/neverIntersectionNotCallable.types
Normal file
11
tests/baselines/reference/neverIntersectionNotCallable.types
Normal file
|
@ -0,0 +1,11 @@
|
|||
=== tests/cases/conformance/types/never/neverIntersectionNotCallable.ts ===
|
||||
declare const f: { (x: string): number, a: "" } & { a: number }
|
||||
>f : never
|
||||
>x : string
|
||||
>a : ""
|
||||
>a : number
|
||||
|
||||
f()
|
||||
>f() : any
|
||||
>f : never
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
declare const f: { (x: string): number, a: "" } & { a: number }
|
||||
f()
|
Loading…
Reference in a new issue