I've noticed it's impossible to check for a function to not be callable with arguments
https://github.com/mmkal/ts/blob/main/packages/expect-type/src/index.ts#L111
In case of negated assertion, the check property is never.
So. I've tweaked around and I think the issue is that typing errors are generated during the last call, where type parameters are merged to generate a MISMATCH, spread as a rest parameter to generate type that can never be instantiated properly. But the current format of toBeCallableWith already takes a rest parameter for args.
So, here is the proposal: create a new method that takes arguments not as a rest tuple, but as a single tuple. Something like this:
export interface ExpectTypeOf<Actual, B extends boolean> {
toBeCallableWithArgs: <T extends any[] | [never]>(args: T, ...MISMATCH: MismatchArgs<Extends<T, Params<Actual>>, B>) => true;
}
Thoughts ?
I've noticed it's impossible to check for a function to not be callable with arguments
https://github.com/mmkal/ts/blob/main/packages/expect-type/src/index.ts#L111
In case of negated assertion, the check property is
never.So. I've tweaked around and I think the issue is that typing errors are generated during the last call, where type parameters are merged to generate a
MISMATCH, spread as a rest parameter to generate type that can never be instantiated properly. But the current format oftoBeCallableWithalready takes a rest parameter for args.So, here is the proposal: create a new method that takes arguments not as a rest tuple, but as a single tuple. Something like this:
Thoughts ?