mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fixed an issue with top function type being callable with no arguments (#52387)
This commit is contained in:
@@ -34609,7 +34609,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
|
||||
function getNonArrayRestType(signature: Signature) {
|
||||
const restType = getEffectiveRestType(signature);
|
||||
return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & TypeFlags.Never) === 0 ? restType : undefined;
|
||||
return restType && !isArrayType(restType) && !isTypeAny(restType) ? restType : undefined;
|
||||
}
|
||||
|
||||
function getTypeOfFirstParameterOfSignature(signature: Signature) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/topFunctionTypeNotCallable.ts(4,1): error TS2345: Argument of type '[]' is not assignable to parameter of type 'never'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/topFunctionTypeNotCallable.ts (1 errors) ====
|
||||
// repro from #48840
|
||||
|
||||
declare let foo: (...args: never) => void;
|
||||
foo(); // error
|
||||
~~~~~
|
||||
!!! error TS2345: Argument of type '[]' is not assignable to parameter of type 'never'.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/topFunctionTypeNotCallable.ts ===
|
||||
// repro from #48840
|
||||
|
||||
declare let foo: (...args: never) => void;
|
||||
>foo : Symbol(foo, Decl(topFunctionTypeNotCallable.ts, 2, 11))
|
||||
>args : Symbol(args, Decl(topFunctionTypeNotCallable.ts, 2, 18))
|
||||
|
||||
foo(); // error
|
||||
>foo : Symbol(foo, Decl(topFunctionTypeNotCallable.ts, 2, 11))
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/compiler/topFunctionTypeNotCallable.ts ===
|
||||
// repro from #48840
|
||||
|
||||
declare let foo: (...args: never) => void;
|
||||
>foo : (...args: never) => void
|
||||
>args : never
|
||||
|
||||
foo(); // error
|
||||
>foo() : void
|
||||
>foo : (...args: never) => void
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// @strict: true
|
||||
// @noEmit: true
|
||||
|
||||
// repro from #48840
|
||||
|
||||
declare let foo: (...args: never) => void;
|
||||
foo(); // error
|
||||
Reference in New Issue
Block a user