Skip to content

Commit

Permalink
[patch] remove .example files and support verbatimModuleSyntax in pac…
Browse files Browse the repository at this point in the history
…kages/assert
  • Loading branch information
electrovir committed Sep 15, 2024
1 parent 51b36e8 commit d8edd20
Show file tree
Hide file tree
Showing 53 changed files with 102 additions and 186 deletions.
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/boolean.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MaybePromise, NarrowToExpected, stringify} from '@augment-vir/core';
import {type MaybePromise, type NarrowToExpected, stringify} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

/**
* All falsy values in JavaScript. This does not include `NaN` because there is no dedicated type
Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/boundary.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MaybePromise, stringify} from '@augment-vir/core';
import {type MaybePromise, stringify} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

/* eslint-disable @typescript-eslint/no-unused-vars */

Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/enum.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {NarrowToExpected} from '@augment-vir/core';
import {EnumBaseType, getEnumValues, MaybePromise} from '@augment-vir/core';
import {type EnumBaseType, getEnumValues, type MaybePromise} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

export function isEnumValue<const Expected extends EnumBaseType>(
child: unknown,
Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/equality/entry-equality.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {NarrowToExpected} from '@augment-vir/core';
import {AnyObject, MaybePromise, stringify} from '@augment-vir/core';
import {type AnyObject, type MaybePromise, stringify} from '@augment-vir/core';
import {AssertionError} from '../../augments/assertion.error.js';
import type {GuardGroup} from '../../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../../guard-types/guard-override.js';
import {WaitUntilOptions} from '../../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../../guard-types/wait-until-function.js';
import {strictEquals} from './simple-equality.js';

function entriesEqual<const Actual extends object, const Expected extends Actual>(
Expand Down
9 changes: 7 additions & 2 deletions packages/assert/src/assertions/equality/json-equality.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import {AnyObject, extractErrorMessage, MaybePromise, NarrowToExpected} from '@augment-vir/core';
import {
type AnyObject,
extractErrorMessage,
type MaybePromise,
type NarrowToExpected,
} from '@augment-vir/core';
import {AssertionError} from '../../augments/assertion.error.js';
import type {GuardGroup} from '../../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../../guard-types/guard-override.js';
import {WaitUntilOptions} from '../../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../../guard-types/wait-until-function.js';

function baseJsonEquals(a: unknown, b: unknown): boolean {
return JSON.stringify(a) === JSON.stringify(b);
Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/equality/simple-equality.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {MaybePromise, NarrowToExpected, stringify} from '@augment-vir/core';
import {type MaybePromise, type NarrowToExpected, stringify} from '@augment-vir/core';
import deepEqual from 'deep-eql';
import {AssertionError} from '../../augments/assertion.error.js';
import type {GuardGroup} from '../../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../../guard-types/guard-override.js';
import {WaitUntilOptions} from '../../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../../guard-types/wait-until-function.js';

export function strictEquals<const Actual, const Expected extends Actual>(
actual: Actual,
Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/equality/ts-type-equality.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ExpectTypeOf} from 'expect-type';
import type {GuardGroup} from '../../guard-types/guard-group.js';
import {type ExpectTypeOf} from 'expect-type';
import {type GuardGroup} from '../../guard-types/guard-group.js';

type AssertTypeOf<TestingType> = {
equals: ExpectTypeOf<TestingType, {positive: true}>['toEqualTypeOf'];
Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/extendable-assertions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {ArrayElement} from '@augment-vir/core';
import type {UnionToIntersection} from 'type-fest';
import {AssertFunction} from '../guard-types/assert-function.js';
import {GuardGroup} from '../guard-types/guard-group.js';
import {type AssertFunction} from '../guard-types/assert-function.js';
import {type GuardGroup} from '../guard-types/guard-group.js';
import {booleanGuards} from './boolean.js';
import {boundaryGuards} from './boundary.js';
import {enumGuards} from './enum.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
type NarrowToExpected,
} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import {GuardGroup} from '../guard-types/guard-group.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../guard-types/guard-override.js';
import type {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {isEnumValue} from './enum.js';
import {isIn} from './values.js';

Expand Down
6 changes: 3 additions & 3 deletions packages/assert/src/assertions/instance.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {MaybePromise, stringify} from '@augment-vir/core';
import {Constructor} from 'type-fest';
import {type MaybePromise, stringify} from '@augment-vir/core';
import {type Constructor} from 'type-fest';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

/** Wraps the JavaScript built-in "instanceof" in a type guard assertion. */
function instanceOf<const Instance>(
Expand Down
11 changes: 8 additions & 3 deletions packages/assert/src/assertions/keys.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {MaybePromise, NarrowToExpected, stringify, type RequiredKeysOf} from '@augment-vir/core';
import {SetRequired} from 'type-fest';
import {
stringify,
type MaybePromise,
type NarrowToExpected,
type RequiredKeysOf,
} from '@augment-vir/core';
import {type SetRequired} from 'type-fest';
import {AssertionError} from '../augments/assertion.error.js';
import {createCheck} from '../guard-types/check-function.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

function isKeyOf<const Parent>(
key: PropertyKey,
Expand Down
6 changes: 3 additions & 3 deletions packages/assert/src/assertions/length.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import {
getObjectTypedKeys,
MaybePromise,
Tuple,
type AnyObject,
type AtLeastTuple,
type MaybePromise,
type Tuple,
} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

function isLengthAtLeast<const Element, const Length extends number>(
actual: ReadonlyArray<Element | undefined>,
Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/nullish.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MaybePromise, stringify} from '@augment-vir/core';
import {type MaybePromise, stringify} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

function isDefined<const Actual>(
/** The value to check. */
Expand Down
19 changes: 0 additions & 19 deletions packages/assert/src/assertions/output.example.ts

This file was deleted.

5 changes: 4 additions & 1 deletion packages/assert/src/assertions/output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import type {
OutputAssertWrapWithoutAsserter,
OutputCheckWithoutAsserter,
} from './output.js';
import {OutputCheckWrapWithoutAsserter, OutputWaitUntilWithoutAsserter} from './output.js';
import {
type OutputCheckWrapWithoutAsserter,
type OutputWaitUntilWithoutAsserter,
} from './output.js';

describe('output', () => {
describe('assert', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/assert/src/assertions/output.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {
AnyFunction,
type AnyFunction,
combineErrorMessages,
ensureError,
ensureErrorAndPrependMessage,
extractErrorMessage,
MaybePromise,
type MaybePromise,
stringify,
wait,
} from '@augment-vir/core';
import {convertDuration, DurationUnit} from '@date-vir/duration';
import type {IsAny} from 'type-fest';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {parseWaitUntilOptions, WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {parseWaitUntilOptions, type WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {deepEquals} from './equality/simple-equality.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/assert/src/assertions/primitive.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {AnyObject} from '@augment-vir/core';
import {describe, type FunctionTestCase, it, itCases} from '@augment-vir/test';
import {Primitive} from 'type-fest';
import {type Primitive} from 'type-fest';
import {assertWrap} from '../augments/guards/assert-wrap.js';
import {assert} from '../augments/guards/assert.js';
import {checkWrap} from '../augments/guards/check-wrap.js';
Expand Down
7 changes: 3 additions & 4 deletions packages/assert/src/assertions/primitive.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type {MaybePromise} from '@augment-vir/core';
import {stringify} from '@augment-vir/core';
import {Primitive} from 'type-fest';
import {stringify, type MaybePromise} from '@augment-vir/core';
import {type Primitive} from 'type-fest';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

export type {Primitive} from 'type-fest';

Expand Down
2 changes: 1 addition & 1 deletion packages/assert/src/assertions/promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {stringify} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../guard-types/guard-override.js';
import {createWaitUntil, WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {createWaitUntil, type WaitUntilOptions} from '../guard-types/wait-until-function.js';

function isPromiseLike(
actual: unknown,
Expand Down
4 changes: 0 additions & 4 deletions packages/assert/src/assertions/runtime-type.example.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/assert/src/assertions/runtime-type.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AnyFunction,
AnyObject,
JsonCompatibleArray,
Expand Down
17 changes: 7 additions & 10 deletions packages/assert/src/assertions/runtime-type.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
AnyFunction,
MaybePromise,
NarrowToActual,
NarrowToExpected,
type AnyFunction,
type MaybePromise,
type NarrowToActual,
type NarrowToExpected,
stringify,
UnknownObject,
type UnknownObject,
} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

type ArrayNarrow<Actual> =
Extract<Actual, unknown[]> extends never
Expand Down Expand Up @@ -612,10 +612,7 @@ export const runtimeTypeGuards = {
*/
isFunction:
autoGuard<
<const Actual>(
actual: Actual,
failureMessage?: string | undefined,
) => actual is NarrowToActual<Actual, AnyFunction>
<const Actual>(actual: Actual) => actual is NarrowToActual<Actual, AnyFunction>
>(),
/**
* Checks that a value is exactly `null`.
Expand Down
15 changes: 0 additions & 15 deletions packages/assert/src/assertions/throws.example.ts

This file was deleted.

10 changes: 5 additions & 5 deletions packages/assert/src/assertions/throws.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {
type AnyFunction,
ensureError,
extractErrorMessage,
MaybePromise,
PartialWithNullable,
type MaybePromise,
type PartialWithNullable,
stringify,
TypedFunction,
type AnyFunction,
type TypedFunction,
} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuardSymbol} from '../guard-types/guard-override.js';
import {createWaitUntil, WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {createWaitUntil, type WaitUntilOptions} from '../guard-types/wait-until-function.js';

enum ThrowsCheckType {
Assert = 'assert',
Expand Down
6 changes: 3 additions & 3 deletions packages/assert/src/assertions/uuid.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {MaybePromise, Uuid} from '@augment-vir/core';
import {type MaybePromise, type Uuid} from '@augment-vir/core';
import {AssertionError} from '../augments/assertion.error.js';
import {GuardGroup} from '../guard-types/guard-group.js';
import {type GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../guard-types/guard-override.js';
import {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;

Expand Down
4 changes: 2 additions & 2 deletions packages/assert/src/assertions/values.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type {NarrowToActual, NarrowToExpected} from '@augment-vir/core';
import {AnyObject, MaybePromise, stringify, Values} from '@augment-vir/core';
import {type AnyObject, type MaybePromise, stringify, type Values} from '@augment-vir/core';
import type {EmptyObject} from 'type-fest';
import {AssertionError} from '../augments/assertion.error.js';
import type {GuardGroup} from '../guard-types/guard-group.js';
import {autoGuard, autoGuardSymbol} from '../guard-types/guard-override.js';
import type {WaitUntilOptions} from '../guard-types/wait-until-function.js';
import {type WaitUntilOptions} from '../guard-types/wait-until-function.js';

function hasValue(parent: object, value: unknown, failureMessage?: string | undefined) {
/** Wrap this in a try/catch because `Reflect.ownKeys` can fail depending on what its input is. */
Expand Down
4 changes: 0 additions & 4 deletions packages/assert/src/augments/assertion.error.example.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/assert/src/augments/guards/assert-wrap.example.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/assert/src/augments/guards/assert.example.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/assert/src/augments/guards/check-wrap.example.ts

This file was deleted.

Loading

0 comments on commit d8edd20

Please sign in to comment.