Update dev dependencies

This commit is contained in:
Sindre Sorhus 2022-10-17 18:02:01 +07:00
parent f3693674f6
commit e559b37b72
4 changed files with 42 additions and 32 deletions

View file

@ -251,7 +251,7 @@ is.sharedArrayBuffer = isObjectOfType<SharedArrayBuffer>('SharedArrayBuffer');
is.dataView = isObjectOfType<DataView>('DataView');
is.enumCase = <T = unknown>(value: unknown, targetEnum: T) => Object.values(targetEnum).includes(value as string);
is.enumCase = <T = unknown>(value: unknown, targetEnum: T): boolean => Object.values(targetEnum as any).includes(value as string);
is.directInstanceOf = <T>(instance: unknown, class_: Class<T>): instance is T => Object.getPrototypeOf(instance) === class_.prototype;
@ -298,10 +298,10 @@ is.plainObject = <Value = unknown>(value: unknown): value is Record<PropertyKey,
is.typedArray = (value: unknown): value is TypedArray => isTypedArrayName(getObjectType(value));
export interface ArrayLike<T> {
export type ArrayLike<T> = {
readonly [index: number]: T;
readonly length: number;
}
};
const isValidLength = (value: unknown): value is number => is.safeInteger(value) && value >= 0;
is.arrayLike = <T = unknown>(value: unknown): value is ArrayLike<T> => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength((value as ArrayLike<T>).length);
@ -354,9 +354,9 @@ is.observable = (value: unknown): value is ObservableLike => {
return false;
};
export interface NodeStream extends NodeJS.EventEmitter {
export type NodeStream = {
pipe<T extends NodeJS.WritableStream>(destination: T, options?: {end?: boolean}): T;
}
} & NodeJS.EventEmitter;
is.nodeStream = (value: unknown): value is NodeStream => is.object(value) && is.function_((value as NodeStream).pipe) && !is.observable(value);
@ -490,7 +490,7 @@ export const enum AssertionTypeDescription {
}
// Type assertions have to be declared with an explicit type.
interface Assert {
type Assert = {
// Unknowns.
undefined: (value: unknown) => asserts value is undefined;
string: (value: unknown) => asserts value is string;
@ -585,7 +585,7 @@ interface Assert {
// Variadic functions.
any: (predicate: Predicate | Predicate[], ...values: unknown[]) => void | never;
all: (predicate: Predicate, ...values: unknown[]) => void | never;
}
};
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
export const assert: Assert = {

View file

@ -15,6 +15,13 @@ export type Primitive =
/**
Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
*/
/// type Constructor<T, Arguments extends unknown[] = any[]> = new(...arguments_: Arguments) => T;
/**
Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
*/
// TODO: Use the below in the next major version.
// export type Class<T, Arguments extends unknown[] = any[]> = Constructor<T, Arguments> & {prototype: T};
export type Class<T = unknown, Arguments extends any[] = any[]> = new (...arguments_: Arguments) => T;
/**
@ -34,6 +41,7 @@ export type TypedArray =
| BigUint64Array;
declare global {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- This must be an `interface` so it can be merged.
interface SymbolConstructor {
readonly observable: symbol;
}
@ -42,15 +50,15 @@ declare global {
/**
Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
*/
export interface ObservableLike {
export type ObservableLike = {
subscribe(observer: (value: unknown) => void): void;
[Symbol.observable](): ObservableLike;
}
};
// eslint-disable-next-line @typescript-eslint/ban-types
export type Falsy = false | 0 | 0n | '' | null | undefined;
export interface WeakRef<T extends object> { // eslint-disable-line @typescript-eslint/ban-types
export type WeakRef<T extends object> = { // eslint-disable-line @typescript-eslint/ban-types
readonly [Symbol.toStringTag]: 'WeakRef';
deref(): T | undefined;
}
};