Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kerosene: Add overload utility types
- Loading branch information
Showing
8 changed files
with
131 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import { OverloadedParameters, OverloadedReturnType } from "@kablamo/kerosene"; | ||
|
||
/** | ||
* Shorthand for `jest.Mock<ReturnType<T>, Parameters<T>>;` | ||
* Shorthand for `jest.Mock<OverloadedReturnType<T>, OverloadedParameters<T>> & T;` | ||
*/ | ||
export type JestMock<T extends (...args: any[]) => any> = jest.Mock< | ||
ReturnType<T>, | ||
Parameters<T> | ||
>; | ||
export type JestMock<T> = jest.Mock< | ||
OverloadedReturnType<T>, | ||
OverloadedParameters<T> | ||
> & | ||
T; | ||
|
||
/** | ||
* Shorthand for `jest.SpyInstance<ReturnType<T>, Parameters<T>>;` | ||
* Shorthand for `jest.SpyInstance<OverloadedReturnType<T>, OverloadedParameters<T>> & T;` | ||
*/ | ||
export type JestSpied<T extends (...args: any[]) => any> = jest.SpyInstance< | ||
ReturnType<T>, | ||
Parameters<T> | ||
>; | ||
export type JestSpied<T> = jest.SpyInstance< | ||
OverloadedReturnType<T>, | ||
OverloadedParameters<T> | ||
> & | ||
T; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
import { OverloadedParameters, OverloadedReturnType } from "@kablamo/kerosene"; | ||
import sinon from "sinon"; | ||
|
||
/** | ||
* Shorthand for `sinon.SinonSpy<Parameters<T>, ReturnType<T>>;` | ||
* Shorthand for `sinon.SinonSpy<OverloadedParameters<T>, OverloadedReturnType<T>> & T;` | ||
*/ | ||
export type SinonSpied<T extends (...args: any[]) => any> = sinon.SinonSpy< | ||
Parameters<T>, | ||
ReturnType<T> | ||
>; | ||
export type SinonSpied<T> = sinon.SinonSpy< | ||
OverloadedParameters<T>, | ||
OverloadedReturnType<T> | ||
> & | ||
T; | ||
|
||
/** | ||
* Shorthand for `sinon.SinonStub<Parameters<T>, ReturnType<T>>;` | ||
* Shorthand for `sinon.SinonStub<OverloadedParameters<T>, OverloadedReturnType<T>> & T;` | ||
*/ | ||
export type SinonStubbed<T extends (...args: any[]) => any> = sinon.SinonStub< | ||
Parameters<T>, | ||
ReturnType<T> | ||
>; | ||
export type SinonStubbed<T> = sinon.SinonStub< | ||
OverloadedParameters<T>, | ||
OverloadedReturnType<T> | ||
> & | ||
T; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters