function foo(a: number, b: number) {
return a + b;
}
type Foo1 = typeof foo extends (...args: unknown[]) => unknown ? true : false; // false
type Foo2 = typeof foo extends (...args: any[]) => unknown ? true : false; // true
What is the reason it functions correctly with any[]
, but not with unknown[]
?
The behavior is successful with tuples and ReturnType
s, but not with rest parameters.
type Foo = ['bar', 'baz'] extends unknown[] ? true : false; // true