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

@ -11,14 +11,16 @@
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"engines": {
"node": ">=14.16"
},
"scripts": {
"build": "del dist && tsc",
"test": "xo && ava",
"test": "tsc --noEmit && xo && ava",
"prepare": "npm run build"
},
"files": [
@ -50,17 +52,17 @@
],
"devDependencies": {
"@sindresorhus/tsconfig": "^3.0.1",
"@types/jsdom": "^16.2.15",
"@types/node": "^18.0.6",
"@types/jsdom": "^20.0.0",
"@types/node": "^18.11.0",
"@types/zen-observable": "^0.8.3",
"ava": "^4.3.1",
"ava": "^4.3.3",
"del-cli": "^5.0.0",
"jsdom": "^20.0.0",
"rxjs": "^7.5.6",
"jsdom": "^20.0.1",
"rxjs": "^7.5.7",
"tempy": "^3.0.0",
"ts-node": "^10.9.1",
"typescript": "~4.7.4",
"xo": "^0.51.0",
"typescript": "~4.8.4",
"xo": "^0.52.4",
"zen-observable": "^0.8.15"
},
"sideEffects": false,
@ -71,12 +73,5 @@
"nodeArguments": [
"--loader=ts-node/esm"
]
},
"xo": {
"rules": {
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/triple-slash-reference": "off"
}
}
}

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;
}
};

View file

@ -1,14 +1,21 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import {Buffer} from 'node:buffer';
import fs from 'node:fs';
import net from 'node:net';
import Stream from 'node:stream';
import {inspect} from 'node:util';
import test, {ExecutionContext} from 'ava';
import test, {type ExecutionContext} from 'ava';
import {JSDOM} from 'jsdom';
import {Subject, Observable} from 'rxjs';
import {temporaryFile} from 'tempy';
import ZenObservable from 'zen-observable';
import is, {assert, AssertionTypeDescription, Primitive, TypedArray, TypeName} from '../source/index.js';
import is, {
assert,
AssertionTypeDescription,
type Primitive,
type TypedArray,
type TypeName,
} from '../source/index.js';
class PromiseSubclassFixture<T> extends Promise<T> {}
class ErrorSubclassFixture extends Error {}
@ -17,13 +24,13 @@ const {window} = new JSDOM();
const {document} = window;
const createDomElement = (element: string) => document.createElement(element);
interface Test {
type Test = {
assert: (...args: any[]) => void | never;
fixtures: unknown[];
typename?: TypeName;
typeDescription?: AssertionTypeDescription | TypeName;
is(value: unknown): boolean;
}
};
const invertAssertThrow = (description: string, fn: () => void | never, value: unknown): void | never => {
const expectedAssertErrorMessage = `Expected value which is \`${description}\`, received value of type \`${is(value)}\`.`;