diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7c7fab735856e..a64d6ebd1e786 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28359,7 +28359,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 { diff --git a/tests/baselines/reference/neverIntersectionNotCallable.errors.txt b/tests/baselines/reference/neverIntersectionNotCallable.errors.txt new file mode 100644 index 0000000000000..5ae3d35a692aa --- /dev/null +++ b/tests/baselines/reference/neverIntersectionNotCallable.errors.txt @@ -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. + \ No newline at end of file diff --git a/tests/baselines/reference/neverIntersectionNotCallable.js b/tests/baselines/reference/neverIntersectionNotCallable.js new file mode 100644 index 0000000000000..b06cd75ee4398 --- /dev/null +++ b/tests/baselines/reference/neverIntersectionNotCallable.js @@ -0,0 +1,7 @@ +//// [neverIntersectionNotCallable.ts] +declare const f: { (x: string): number, a: "" } & { a: number } +f() + + +//// [neverIntersectionNotCallable.js] +f(); diff --git a/tests/baselines/reference/neverIntersectionNotCallable.symbols b/tests/baselines/reference/neverIntersectionNotCallable.symbols new file mode 100644 index 0000000000000..129b73cb84a99 --- /dev/null +++ b/tests/baselines/reference/neverIntersectionNotCallable.symbols @@ -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)) + diff --git a/tests/baselines/reference/neverIntersectionNotCallable.types b/tests/baselines/reference/neverIntersectionNotCallable.types new file mode 100644 index 0000000000000..1225532a5c406 --- /dev/null +++ b/tests/baselines/reference/neverIntersectionNotCallable.types @@ -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 + diff --git a/tests/cases/conformance/types/never/neverIntersectionNotCallable.ts b/tests/cases/conformance/types/never/neverIntersectionNotCallable.ts new file mode 100644 index 0000000000000..1d38fdebde9b5 --- /dev/null +++ b/tests/cases/conformance/types/never/neverIntersectionNotCallable.ts @@ -0,0 +1,2 @@ +declare const f: { (x: string): number, a: "" } & { a: number } +f()