Skip to content

Commit 0f8d091

Browse files
committed
Fixed an issue with top function type being callable with no arguments
1 parent 31b4ec5 commit 0f8d091

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34383,7 +34383,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3438334383

3438434384
function getNonArrayRestType(signature: Signature) {
3438534385
const restType = getEffectiveRestType(signature);
34386-
return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & TypeFlags.Never) === 0 ? restType : undefined;
34386+
return restType && !isArrayType(restType) && !isTypeAny(restType) ? restType : undefined;
3438734387
}
3438834388

3438934389
function getTypeOfFirstParameterOfSignature(signature: Signature) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tests/cases/compiler/topFunctionTypeNotCallable.ts(4,1): error TS2345: Argument of type '[]' is not assignable to parameter of type 'never'.
2+
3+
4+
==== tests/cases/compiler/topFunctionTypeNotCallable.ts (1 errors) ====
5+
// repro from #48840
6+
7+
declare let foo: (...args: never) => void;
8+
foo(); // error
9+
~~~~~
10+
!!! error TS2345: Argument of type '[]' is not assignable to parameter of type 'never'.
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/topFunctionTypeNotCallable.ts ===
2+
// repro from #48840
3+
4+
declare let foo: (...args: never) => void;
5+
>foo : Symbol(foo, Decl(topFunctionTypeNotCallable.ts, 2, 11))
6+
>args : Symbol(args, Decl(topFunctionTypeNotCallable.ts, 2, 18))
7+
8+
foo(); // error
9+
>foo : Symbol(foo, Decl(topFunctionTypeNotCallable.ts, 2, 11))
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/compiler/topFunctionTypeNotCallable.ts ===
2+
// repro from #48840
3+
4+
declare let foo: (...args: never) => void;
5+
>foo : (...args: never) => void
6+
>args : never
7+
8+
foo(); // error
9+
>foo() : void
10+
>foo : (...args: never) => void
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @strict: true
2+
// @noEmit: true
3+
4+
// repro from #48840
5+
6+
declare let foo: (...args: never) => void;
7+
foo(); // error

0 commit comments

Comments
 (0)