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" "url": "https://sindresorhus.com"
}, },
"type": "module", "type": "module",
"exports": "./dist/index.js", "exports": {
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"engines": { "engines": {
"node": ">=14.16" "node": ">=14.16"
}, },
"scripts": { "scripts": {
"build": "del dist && tsc", "build": "del dist && tsc",
"test": "xo && ava", "test": "tsc --noEmit && xo && ava",
"prepare": "npm run build" "prepare": "npm run build"
}, },
"files": [ "files": [
@ -50,17 +52,17 @@
], ],
"devDependencies": { "devDependencies": {
"@sindresorhus/tsconfig": "^3.0.1", "@sindresorhus/tsconfig": "^3.0.1",
"@types/jsdom": "^16.2.15", "@types/jsdom": "^20.0.0",
"@types/node": "^18.0.6", "@types/node": "^18.11.0",
"@types/zen-observable": "^0.8.3", "@types/zen-observable": "^0.8.3",
"ava": "^4.3.1", "ava": "^4.3.3",
"del-cli": "^5.0.0", "del-cli": "^5.0.0",
"jsdom": "^20.0.0", "jsdom": "^20.0.1",
"rxjs": "^7.5.6", "rxjs": "^7.5.7",
"tempy": "^3.0.0", "tempy": "^3.0.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "~4.7.4", "typescript": "~4.8.4",
"xo": "^0.51.0", "xo": "^0.52.4",
"zen-observable": "^0.8.15" "zen-observable": "^0.8.15"
}, },
"sideEffects": false, "sideEffects": false,
@ -71,12 +73,5 @@
"nodeArguments": [ "nodeArguments": [
"--loader=ts-node/esm" "--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.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; 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)); is.typedArray = (value: unknown): value is TypedArray => isTypedArrayName(getObjectType(value));
export interface ArrayLike<T> { export type ArrayLike<T> = {
readonly [index: number]: T; readonly [index: number]: T;
readonly length: number; readonly length: number;
} };
const isValidLength = (value: unknown): value is number => is.safeInteger(value) && value >= 0; 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); 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; return false;
}; };
export interface NodeStream extends NodeJS.EventEmitter { export type NodeStream = {
pipe<T extends NodeJS.WritableStream>(destination: T, options?: {end?: boolean}): T; 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); 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. // Type assertions have to be declared with an explicit type.
interface Assert { type Assert = {
// Unknowns. // Unknowns.
undefined: (value: unknown) => asserts value is undefined; undefined: (value: unknown) => asserts value is undefined;
string: (value: unknown) => asserts value is string; string: (value: unknown) => asserts value is string;
@ -585,7 +585,7 @@ interface Assert {
// Variadic functions. // Variadic functions.
any: (predicate: Predicate | Predicate[], ...values: unknown[]) => void | never; any: (predicate: Predicate | Predicate[], ...values: unknown[]) => void | never;
all: (predicate: Predicate, ...values: unknown[]) => void | never; all: (predicate: Predicate, ...values: unknown[]) => void | never;
} };
/* eslint-disable @typescript-eslint/no-confusing-void-expression */ /* eslint-disable @typescript-eslint/no-confusing-void-expression */
export const assert: Assert = { 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). 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; export type Class<T = unknown, Arguments extends any[] = any[]> = new (...arguments_: Arguments) => T;
/** /**
@ -34,6 +41,7 @@ export type TypedArray =
| BigUint64Array; | BigUint64Array;
declare global { declare global {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- This must be an `interface` so it can be merged.
interface SymbolConstructor { interface SymbolConstructor {
readonly observable: symbol; readonly observable: symbol;
} }
@ -42,15 +50,15 @@ declare global {
/** /**
Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable). 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; subscribe(observer: (value: unknown) => void): void;
[Symbol.observable](): ObservableLike; [Symbol.observable](): ObservableLike;
} };
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
export type Falsy = false | 0 | 0n | '' | null | undefined; 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'; readonly [Symbol.toStringTag]: 'WeakRef';
deref(): T | undefined; deref(): T | undefined;
} };

View file

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