Skip to content

Commit

Permalink
fix(type-factories): Correct types on instanceOf type factory (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseLion authored Nov 22, 2022
1 parent 479d3bc commit c00bd31
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/lib/helpers/TypeFactories.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ArrayAssertion } from "../ArrayAssertion";
import { Assertion } from "../Assertion";
import { Assertion, Constructor } from "../Assertion";
import { BooleanAssertion } from "../BooleanAssertion";
import { DateAssertion } from "../DateAssertion";
import { AnyFunction, FunctionAssertion } from "../FunctionAssertion";
Expand Down Expand Up @@ -84,7 +84,7 @@ export interface StaticTypeFactories {
* @typeParam T the type of the instance constructor
* @param Type the instance constructor
*/
instanceOf<T extends new (...args: any[]) => any>(Type: T): TypeFactory<T, Assertion<T>>;
instanceOf<T>(Type: Constructor<T>): TypeFactory<T, Assertion<T>>;
/**
* Creates a TypeFactory for a Javascript Object.
*
Expand Down Expand Up @@ -138,10 +138,10 @@ export const TypeFactories: Readonly<StaticTypeFactories> = {
typeName: "array"
};
},
instanceOf(type) {
instanceOf<T>(type: Constructor<T>) {
return {
Factory: Assertion,
predicate: (value): value is typeof type => value instanceof type,
predicate: (value): value is T => value instanceof type,
typeName: type.name
};
},
Expand Down

0 comments on commit c00bd31

Please sign in to comment.