diff --git a/source/index.ts b/source/index.ts index a3a7cf3..fb552f6 100644 --- a/source/index.ts +++ b/source/index.ts @@ -236,14 +236,10 @@ const is = Object.assign( boundFunction: isBoundFunction, buffer: isBuffer, class: isClass, - /** @deprecated Renamed to `class`. */ - class_: isClass, dataView: isDataView, date: isDate, detect, directInstanceOf: isDirectInstanceOf, - /** @deprecated Renamed to `htmlElement` */ - domElement: isHtmlElement, emptyArray: isEmptyArray, emptyMap: isEmptyMap, emptyObject: isEmptyObject, @@ -258,8 +254,6 @@ const is = Object.assign( float64Array: isFloat64Array, formData: isFormData, function: isFunction, - /** @deprecated Renamed to `function`. */ - function_: isFunction, generator: isGenerator, generatorFunction: isGeneratorFunction, htmlElement: isHtmlElement, @@ -282,8 +276,6 @@ const is = Object.assign( nonEmptyString: isNonEmptyString, nonEmptyStringAndNotWhitespace: isNonEmptyStringAndNotWhitespace, null: isNull, - /** @deprecated Renamed to `null`. */ - null_: isNull, nullOrUndefined: isNullOrUndefined, number: isNumber, numericString: isNumericString, @@ -403,7 +395,7 @@ export function isBuffer(value: unknown): value is Buffer { return (value as any)?.constructor?.isBuffer?.(value) ?? false; } -export function isClass(value: unknown): value is Class { +export function isClass(value: unknown): value is Class { return isFunction(value) && value.toString().startsWith('class '); } @@ -832,17 +824,9 @@ type Assert = { bigint: (value: unknown, message?: string) => asserts value is bigint; // eslint-disable-next-line @typescript-eslint/ban-types function: (value: unknown, message?: string) => asserts value is Function; - /** @deprecated Renamed to `function`. */ - // eslint-disable-next-line @typescript-eslint/ban-types - function_: (value: unknown, message?: string) => asserts value is Function; // eslint-disable-next-line @typescript-eslint/ban-types null: (value: unknown, message?: string) => asserts value is null; - /** @deprecated Renamed to `null`. */ - // eslint-disable-next-line @typescript-eslint/ban-types - null_: (value: unknown, message?: string) => asserts value is null; - class: (value: unknown, message?: string) => asserts value is Class; - /** @deprecated Renamed to `class`. */ - class_: (value: unknown, message?: string) => asserts value is Class; + class: (value: unknown, message?: string) => asserts value is Class; boolean: (value: unknown, message?: string) => asserts value is boolean; symbol: (value: unknown, message?: string) => asserts value is symbol; numericString: (value: unknown, message?: string) => asserts value is `${number}`; @@ -902,8 +886,6 @@ type Assert = { typedArray: (value: unknown, message?: string) => asserts value is TypedArray; arrayLike: (value: unknown, message?: string) => asserts value is ArrayLike; tupleLike: >>(value: unknown, guards: [...T], message?: string) => asserts value is ResolveTypesOfTypeGuardsTuple; - /** @deprecated Renamed to `htmlElement` */ - domElement: (value: unknown, message?: string) => asserts value is HTMLElement; htmlElement: (value: unknown, message?: string) => asserts value is HTMLElement; observable: (value: unknown, message?: string) => asserts value is ObservableLike; nodeStream: (value: unknown, message?: string) => asserts value is NodeStream; @@ -958,11 +940,9 @@ export const assert: Assert = { boundFunction: assertBoundFunction, buffer: assertBuffer, class: assertClass, - class_: assertClass, dataView: assertDataView, date: assertDate, directInstanceOf: assertDirectInstanceOf, - domElement: assertHtmlElement, emptyArray: assertEmptyArray, emptyMap: assertEmptyMap, emptyObject: assertEmptyObject, @@ -977,7 +957,6 @@ export const assert: Assert = { float64Array: assertFloat64Array, formData: assertFormData, function: assertFunction, - function_: assertFunction, generator: assertGenerator, generatorFunction: assertGeneratorFunction, htmlElement: assertHtmlElement, @@ -1000,7 +979,6 @@ export const assert: Assert = { nonEmptyString: assertNonEmptyString, nonEmptyStringAndNotWhitespace: assertNonEmptyStringAndNotWhitespace, null: assertNull, - null_: assertNull, nullOrUndefined: assertNullOrUndefined, number: assertNumber, numericString: assertNumericString, @@ -1056,8 +1034,6 @@ const methodTypeMap = { isDataView: 'DataView', isDate: 'Date', isDirectInstanceOf: 'T', - /** @deprecated */ - isDomElement: 'HTMLElement', isEmptyArray: 'empty array', isEmptyMap: 'empty map', isEmptyObject: 'empty object', @@ -1247,7 +1223,7 @@ export function assertBuffer(value: unknown, message?: string): asserts value is } } -export function assertClass(value: unknown, message?: string): asserts value is Class { +export function assertClass(value: unknown, message?: string): asserts value is Class { if (!isClass(value)) { throw new TypeError(message ?? typeErrorMessage('Class', value)); } diff --git a/source/types.ts b/source/types.ts index e77d73a..56f62a7 100644 --- a/source/types.ts +++ b/source/types.ts @@ -15,14 +15,12 @@ export type Primitive = /** Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes). */ -/// type Constructor = new(...arguments_: Arguments) => T; +type Constructor = 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 = Constructor & {prototype: T}; -export type Class = new (...arguments_: Arguments) => T; +export type Class = Constructor & {prototype: T}; /** Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`. diff --git a/test/test.ts b/test/test.ts index a02026e..4086a18 100644 --- a/test/test.ts +++ b/test/test.ts @@ -61,7 +61,7 @@ const types = new Map([ }], ['null', { is: is.null, - assert: assert.null_, + assert: assert.null, fixtures: [ null, ], @@ -161,7 +161,7 @@ const types = new Map([ }], ['function', { is: is.function, - assert: assert.function_, + assert: assert.function, fixtures: [ function foo() {}, // eslint-disable-line func-names function () {}, @@ -840,7 +840,7 @@ test('is.asyncFunction', t => { t.true(is.function(fixture().then)); t.notThrows(() => { - assert.function_(fixture().then); + assert.function(fixture().then); }); } }); @@ -1370,7 +1370,7 @@ test('is.class', t => { t.true(is.class(classDeclaration)); t.notThrows(() => { - assert.class_(classDeclaration); + assert.class(classDeclaration); }); } });