mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-29 00:06:17 -05:00
Fixed an issue with top function type being callable with no arguments (#52387)
This commit is contained in:
committed by
GitHub
parent
6b75ce23ce
commit
02885b1a2e
@@ -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'.
|
||||
|
||||
10
tests/baselines/reference/topFunctionTypeNotCallable.symbols
Normal file
10
tests/baselines/reference/topFunctionTypeNotCallable.symbols
Normal file
@@ -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))
|
||||
|
||||
11
tests/baselines/reference/topFunctionTypeNotCallable.types
Normal file
11
tests/baselines/reference/topFunctionTypeNotCallable.types
Normal file
@@ -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
|
||||
|
||||
7
tests/cases/compiler/topFunctionTypeNotCallable.ts
Normal file
7
tests/cases/compiler/topFunctionTypeNotCallable.ts
Normal file
@@ -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