@shedevro/assert
Version:
Assertion typescript library for better, comfortable and safe coding. See readme!
91 lines (90 loc) • 4.31 kB
TypeScript
import type { InstanceClass } from '@shedevro/core';
declare namespace InstanceOf {
namespace Asserts {
type One = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T, message?: string): asserts value is InstanceType<T>;
};
type OneNullable = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T, message?: string): asserts value is InstanceType<T> | null;
};
type Array = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T, message?: string): asserts value is InstanceType<T>[];
};
type ArrayNullable = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T, message?: string): asserts value is InstanceType<T>[] | null;
};
type Not = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T, message?: string): void;
};
}
namespace ValueIs {
type One = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T): value is InstanceType<T>;
};
type OneNullable = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T): value is InstanceType<T> | null;
};
type Array = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T): value is InstanceType<T>[];
};
type ArrayNullable = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T): value is InstanceType<T>[] | null;
};
type Not = {
instanceOf<T extends InstanceClass>(value: unknown, instanceClass: T): void;
};
}
}
declare namespace InstanceOfAny {
namespace Asserts {
type One = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[], message?: string): asserts value is T;
};
type OneNullable = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[], message?: string): asserts value is T | null;
};
type Array = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[], message?: string): asserts value is T[];
};
type ArrayNullable = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[], message?: string): asserts value is T[] | null;
};
type Not = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[], message?: string): boolean;
};
}
namespace ValueIs {
type One = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[]): value is T;
};
type OneNullable = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[]): value is T | null;
};
type Array = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[]): value is T[];
};
type ArrayNullable = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[]): value is T[] | null;
};
type Not = {
instanceOfAny<T extends InstanceClass>(value: unknown, instanceClasses: T[]): boolean;
};
}
}
export declare namespace InstanceFunctions {
namespace Asserts {
type One = InstanceOf.Asserts.One & InstanceOfAny.Asserts.One;
type OneNullable = InstanceOf.Asserts.OneNullable & InstanceOfAny.Asserts.OneNullable;
type Array = InstanceOf.Asserts.Array & InstanceOfAny.Asserts.ArrayNullable;
type ArrayNullable = InstanceOf.Asserts.ArrayNullable & InstanceOfAny.Asserts.ArrayNullable;
type Not = InstanceOf.Asserts.Not & InstanceOfAny.Asserts.Not;
}
namespace ValueIs {
type One = InstanceOf.ValueIs.One & InstanceOfAny.ValueIs.One;
type OneNullable = InstanceOf.ValueIs.OneNullable & InstanceOfAny.ValueIs.OneNullable;
type Array = InstanceOf.ValueIs.Array & InstanceOfAny.ValueIs.ArrayNullable;
type ArrayNullable = InstanceOf.ValueIs.ArrayNullable & InstanceOfAny.ValueIs.ArrayNullable;
type Not = InstanceOf.ValueIs.Not & InstanceOfAny.ValueIs.Not;
}
}
export {};