From e926db312c4ede1be19df88da95c0bf46f83c7fc Mon Sep 17 00:00:00 2001 From: Milly Date: Sun, 8 Sep 2024 03:24:21 +0900 Subject: [PATCH 1/3] deps: bump @std/assert version from ^0.221.0 to ^1.0.4 --- deno.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno.jsonc b/deno.jsonc index 7d5c5be..0f59af7 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -75,7 +75,7 @@ "@core/iterutil": "jsr:@core/iterutil@^0.3.0", "@core/unknownutil": "./mod.ts", "@deno/dnt": "jsr:@deno/dnt@^0.41.1", - "@std/assert": "jsr:@std/assert@^0.221.0", + "@std/assert": "jsr:@std/assert@^1.0.4", "@std/jsonc": "jsr:@std/jsonc@^1.0.0", "@std/path": "jsr:@std/path@^1.0.2", "@std/testing": "jsr:@std/testing@^0.221.0" From 900a85592dc42728e15394fde5869228bb812cd3 Mon Sep 17 00:00:00 2001 From: Milly Date: Sun, 8 Sep 2024 03:26:41 +0900 Subject: [PATCH 2/3] deps: bump @std/testing version from ^0.221.0 to ^1.0.2 --- deno.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno.jsonc b/deno.jsonc index 0f59af7..9c1ebc1 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -78,7 +78,7 @@ "@std/assert": "jsr:@std/assert@^1.0.4", "@std/jsonc": "jsr:@std/jsonc@^1.0.0", "@std/path": "jsr:@std/path@^1.0.2", - "@std/testing": "jsr:@std/testing@^0.221.0" + "@std/testing": "jsr:@std/testing@^1.0.2" }, "tasks": { "check": "deno check **/*.ts", From 37a93ccc022f20c02a9d7d3a50c9d61732417107 Mon Sep 17 00:00:00 2001 From: Milly Date: Sun, 8 Sep 2024 03:36:38 +0900 Subject: [PATCH 3/3] test: use `IsExact` of @std/testing `IsExact` false positives have been fixed in @std/testing@1.0.1. https://github.com/denoland/std/pull/5676 --- _testutil.ts | 11 ---------- _testutil_test.ts | 43 ------------------------------------- as/optional_test.ts | 18 ++++++++-------- as/readonly_test.ts | 21 ++++++++++-------- is/array_of_test.ts | 5 ++--- is/instance_of_test.ts | 9 ++++---- is/intersection_of_test.ts | 19 ++++++++-------- is/literal_of_test.ts | 19 ++++++++-------- is/literal_one_of_test.ts | 5 ++--- is/map_of_test.ts | 7 +++--- is/object_of_test.ts | 11 +++++----- is/omit_of_test.ts | 11 +++++----- is/parameters_of_test.ts | 7 +++--- is/partial_of_test.ts | 7 +++--- is/pick_of_test.ts | 11 +++++----- is/readonly_of_test.ts | 13 ++++++----- is/record_object_of_test.ts | 9 ++++---- is/record_of_test.ts | 9 ++++---- is/required_of_test.ts | 7 +++--- is/set_of_test.ts | 5 ++--- is/strict_of_test.ts | 9 ++++---- is/tuple_of_test.ts | 11 +++++----- is/uniform_tuple_of_test.ts | 7 +++--- is/union_of_test.ts | 8 +++---- 24 files changed, 106 insertions(+), 176 deletions(-) delete mode 100644 _testutil_test.ts diff --git a/_testutil.ts b/_testutil.ts index 4ebac02..a0f0dd4 100644 --- a/_testutil.ts +++ b/_testutil.ts @@ -1,5 +1,4 @@ import { assertEquals } from "@std/assert"; -import type { IsExact } from "@std/testing/types"; import type { Predicate } from "./type.ts"; const examples = { @@ -50,16 +49,6 @@ export async function testWithExamples( } } -// It seems 'IsExact' in deno_std is false positive so use `Equal` in type-challenges -// https://github.com/type-challenges/type-challenges/blob/e77262dba62e9254451f661cb4fe5517ffd1d933/utils/index.d.ts#L7-L9 -/** @deprecated use {@linkcode Equal} */ -export type TypeChallengesEqual = (() => T extends X ? 1 : 2) extends - (() => T extends Y ? 1 : 2) ? true : false; - -// `Equal` in type-challenges is false positive so combine `IsExact` + `Equal`. -export type Equal = TypeChallengesEqual extends true ? IsExact - : false; - export function stringify(x: unknown): string { if (x instanceof Date) return `Date(${x.valueOf()})`; if (x instanceof Promise) return "Promise"; diff --git a/_testutil_test.ts b/_testutil_test.ts deleted file mode 100644 index 19c207f..0000000 --- a/_testutil_test.ts +++ /dev/null @@ -1,43 +0,0 @@ -// deno-lint-ignore-file no-explicit-any -import { assertType, type IsExact } from "@std/testing/types"; - -import type { Equal, TypeChallengesEqual } from "./_testutil.ts"; - -declare class Foo { - declare private _: T; -} - -Deno.test("IsExact gives false positive", () => { - // all of the following should be false - assertType void, (x?: number) => void>>(true); - assertType, Foo<{ x: 1; b?: 1 }>>>(true); - assertType any, () => number>>(true); - assertType, Foo>>(true); - assertType>(true); -}); - -Deno.test("TypeChallengesEqual gives false positive", () => { - // all of the following should be false - assertType>(true); - assertType>(true); -}); - -Deno.test("Equal", async (t) => { - await t.step( - "should be correct in cases where IsExact gives false positive", - () => { - assertType void, (x?: number) => void>>(false); - assertType, Foo<{ x: 1; b?: 1 }>>>(false); - assertType any, () => number>>(false); - assertType, Foo>>(false); - assertType>(false); - }, - ); - await t.step( - "should be correct in cases where TypeChallengesEqual gives false positive", - () => { - assertType>(false); - assertType>(false); - }, - ); -}); diff --git a/as/optional_test.ts b/as/optional_test.ts index 8516acb..77437b8 100644 --- a/as/optional_test.ts +++ b/as/optional_test.ts @@ -1,6 +1,6 @@ import { assertEquals } from "@std/assert"; -import { assertType } from "@std/testing/types"; -import { type Equal, testWithExamples } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; +import { testWithExamples } from "../_testutil.ts"; import { is } from "../is/mod.ts"; import type { AsOptional } from "../_annotation.ts"; import { asOptional, asUnoptional, hasOptional } from "./optional.ts"; @@ -35,7 +35,7 @@ Deno.test("asOptional", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal< + IsExact< typeof v, { a: number; b?: number | undefined; c?: number | undefined } > @@ -56,7 +56,7 @@ Deno.test("asOptional", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal + IsExact >( true, ); @@ -76,7 +76,7 @@ Deno.test("asOptional", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal< + IsExact< typeof v, [number, (number | undefined)?, (number | undefined)?] > @@ -117,7 +117,7 @@ Deno.test("asUnoptional", async (t) => { await t.step("predicated type is correct", () => { const v: unknown = undefined; if (pred(v)) { - assertType>( + assertType>( true, ); } @@ -134,7 +134,7 @@ Deno.test("asUnoptional", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal + IsExact >( true, ); @@ -154,7 +154,7 @@ Deno.test("asUnoptional", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal + IsExact >( true, ); @@ -178,7 +178,7 @@ Deno.test("hasOptional

", async (t) => { const pred = asOptional(is.Number); type P = typeof pred; if (hasOptional(pred)) { - assertType>>(true); + assertType>>(true); } }); }); diff --git a/as/readonly_test.ts b/as/readonly_test.ts index 820086d..09755cc 100644 --- a/as/readonly_test.ts +++ b/as/readonly_test.ts @@ -1,6 +1,6 @@ import { assertEquals } from "@std/assert"; -import { assertType } from "@std/testing/types"; -import { type Equal, testWithExamples } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; +import { testWithExamples } from "../_testutil.ts"; import { is } from "../is/mod.ts"; import type { AsReadonly } from "../_annotation.ts"; import { asReadonly, asUnreadonly, hasReadonly } from "./readonly.ts"; @@ -35,7 +35,10 @@ Deno.test("asReadonly", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal + IsExact< + typeof v, + { a: number; readonly b: number; readonly c: number } + > >( true, ); @@ -53,7 +56,7 @@ Deno.test("asReadonly", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal + IsExact >( true, ); @@ -73,7 +76,7 @@ Deno.test("asReadonly", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal + IsExact >( true, ); @@ -111,7 +114,7 @@ Deno.test("asUnreadonly", async (t) => { await t.step("predicated type is correct", () => { const v: unknown = undefined; if (pred(v)) { - assertType>( + assertType>( true, ); } @@ -128,7 +131,7 @@ Deno.test("asUnreadonly", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal + IsExact >( true, ); @@ -148,7 +151,7 @@ Deno.test("asUnreadonly", async (t) => { const v: unknown = undefined; if (pred(v)) { assertType< - Equal + IsExact >( true, ); @@ -172,7 +175,7 @@ Deno.test("hasReadonly

", async (t) => { const pred = asReadonly(is.Number); type P = typeof pred; if (hasReadonly(pred)) { - assertType>(true); + assertType>(true); } }); }); diff --git a/is/array_of_test.ts b/is/array_of_test.ts index 2944a77..2c26602 100644 --- a/is/array_of_test.ts +++ b/is/array_of_test.ts @@ -1,6 +1,5 @@ import { assertEquals } from "@std/assert"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isArrayOf } from "./array_of.ts"; @@ -30,7 +29,7 @@ Deno.test("isArrayOf", async (t) => { const a: unknown = undefined; if (isArrayOf(is.Number)(a)) { - assertType>(true); + assertType>(true); } }); }); diff --git a/is/instance_of_test.ts b/is/instance_of_test.ts index a8fa635..024f689 100644 --- a/is/instance_of_test.ts +++ b/is/instance_of_test.ts @@ -1,6 +1,5 @@ import { assertEquals } from "@std/assert"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { isInstanceOf } from "./instance_of.ts"; Deno.test("isInstanceOf", async (t) => { @@ -29,15 +28,15 @@ Deno.test("isInstanceOf", async (t) => { const a: unknown = undefined; if (isInstanceOf(Cls)(a)) { - assertType>(true); + assertType>(true); } if (isInstanceOf(Date)(a)) { - assertType>(true); + assertType>(true); } if (isInstanceOf(Promise)(a)) { - assertType>>(true); + assertType>>(true); } }); }); diff --git a/is/intersection_of_test.ts b/is/intersection_of_test.ts index c0f474b..df48997 100644 --- a/is/intersection_of_test.ts +++ b/is/intersection_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isIntersectionOf } from "./intersection_of.ts"; @@ -40,16 +39,16 @@ Deno.test("isIntersectionOf", async (t) => { const a: unknown = undefined; if (isIntersectionOf([is.String])(a)) { - assertType>(true); + assertType>(true); } if (isIntersectionOf(objPreds)(a)) { - assertType>(true); + assertType>(true); } if (isIntersectionOf(mixPreds)(a)) { assertType< - Equal< + IsExact< typeof a, & ((...args: unknown[]) => unknown) & { b: string } @@ -70,7 +69,7 @@ Deno.test("isIntersectionOf", async (t) => { if (pred(a)) { assertType< - Equal< + IsExact< typeof a, { id: string } & ({ result: string } | { error: string }) > @@ -114,16 +113,16 @@ Deno.test("isIntersectionOf", async (t) => { const a: unknown = undefined; if (isIntersectionOf([is.String])(a)) { - assertType>(true); + assertType>(true); } if (isIntersectionOf(objPreds)(a)) { - assertType>(true); + assertType>(true); } if (isIntersectionOf(mixPreds)(a)) { assertType< - Equal< + IsExact< typeof a, & ((...args: unknown[]) => unknown) & { [b]: string } @@ -144,7 +143,7 @@ Deno.test("isIntersectionOf", async (t) => { if (pred(a)) { assertType< - Equal< + IsExact< typeof a, { id: string } & ({ result: string } | { error: string }) > diff --git a/is/literal_of_test.ts b/is/literal_of_test.ts index f8a9b75..233129d 100644 --- a/is/literal_of_test.ts +++ b/is/literal_of_test.ts @@ -1,6 +1,5 @@ import { assertEquals } from "@std/assert"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { isLiteralOf } from "./literal_of.ts"; Deno.test("isLiteralOf", async (t) => { @@ -45,35 +44,35 @@ Deno.test("isLiteralOf", async (t) => { const a: unknown = undefined; if (isLiteralOf("hello")(a)) { - assertType>(true); + assertType>(true); } if (isLiteralOf(100)(a)) { - assertType>(true); + assertType>(true); } if (isLiteralOf(100n)(a)) { - assertType>(true); + assertType>(true); } if (isLiteralOf(true)(a)) { - assertType>(true); + assertType>(true); } if (isLiteralOf(false)(a)) { - assertType>(true); + assertType>(true); } if (isLiteralOf(null)(a)) { - assertType>(true); + assertType>(true); } if (isLiteralOf(undefined)(a)) { - assertType>(true); + assertType>(true); } if (isLiteralOf(s)(a)) { - assertType>(true); + assertType>(true); } }); }); diff --git a/is/literal_one_of_test.ts b/is/literal_one_of_test.ts index ecea097..23ee172 100644 --- a/is/literal_one_of_test.ts +++ b/is/literal_one_of_test.ts @@ -1,6 +1,5 @@ import { assertEquals } from "@std/assert"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { isLiteralOneOf } from "./literal_one_of.ts"; Deno.test("isLiteralOneOf", async (t) => { @@ -26,7 +25,7 @@ Deno.test("isLiteralOneOf", async (t) => { await t.step("returns proper type predicate", () => { const a: unknown = "hello"; if (isLiteralOneOf(literals)(a)) { - assertType>(true); + assertType>(true); } }); }); diff --git a/is/map_of_test.ts b/is/map_of_test.ts index 2ebb16f..56519d0 100644 --- a/is/map_of_test.ts +++ b/is/map_of_test.ts @@ -1,6 +1,5 @@ import { assertEquals } from "@std/assert"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isMapOf } from "./map_of.ts"; @@ -29,7 +28,7 @@ Deno.test("isMapOf", async (t) => { await t.step("returns proper type predicate", () => { const a: unknown = undefined; if (isMapOf(is.Number)(a)) { - assertType>>(true); + assertType>>(true); } }); }); @@ -68,7 +67,7 @@ Deno.test("isMapOf", async (t) => { await t.step("predicated type is correct", () => { const a: unknown = new Map([["a", 0]]); if (isMapOf(is.Number, is.String)(a)) { - assertType>>(true); + assertType>>(true); } }); }); diff --git a/is/object_of_test.ts b/is/object_of_test.ts index 38eca30..4d7c8ad 100644 --- a/is/object_of_test.ts +++ b/is/object_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { as } from "../as/mod.ts"; import { isObjectOf } from "./object_of.ts"; @@ -81,12 +80,12 @@ Deno.test("isObjectOf", async (t) => { const a: unknown = { a: 0, b: "a", c: true }; if (isObjectOf(predObj)(a)) { - assertType>(true); + assertType>(true); } if (isObjectOf(predObj2)(a)) { assertType< - Equal< + IsExact< typeof a, { readonly a?: string | undefined; @@ -240,7 +239,7 @@ Deno.test("isObjectOf", async (t) => { if (isObjectOf(predObj)(x)) { assertType< - Equal< + IsExact< typeof x, { a: number; @@ -253,7 +252,7 @@ Deno.test("isObjectOf", async (t) => { if (isObjectOf(predObj2)(x)) { assertType< - Equal< + IsExact< typeof x, { readonly [a]?: string | undefined; diff --git a/is/omit_of_test.ts b/is/omit_of_test.ts index 01d7935..118ef10 100644 --- a/is/omit_of_test.ts +++ b/is/omit_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isOmitOf } from "./omit_of.ts"; @@ -44,13 +43,13 @@ Deno.test("isOmitOf", async (t) => { if (isOmitOf(pred, ["b"])(a)) { assertType< - Equal + IsExact >(true); } if (isOmitOf(isOmitOf(pred, ["b"]), ["c"])(a)) { assertType< - Equal + IsExact >(true); } }); @@ -96,13 +95,13 @@ Deno.test("isOmitOf", async (t) => { if (isOmitOf(pred, [b])(x)) { assertType< - Equal + IsExact >(true); } if (isOmitOf(isOmitOf(pred, [b]), [c])(x)) { assertType< - Equal + IsExact >(true); } }); diff --git a/is/parameters_of_test.ts b/is/parameters_of_test.ts index bbeea8d..6d427a1 100644 --- a/is/parameters_of_test.ts +++ b/is/parameters_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { as } from "../as/mod.ts"; import { is } from "./mod.ts"; import { isParametersOf } from "./parameters_of.ts"; @@ -55,7 +54,7 @@ Deno.test("isParametersOf", async (t) => { const a: unknown = [0, "a"]; if (isParametersOf(predTup)(a)) { assertType< - Equal< + IsExact< typeof a, [ number | undefined, @@ -166,7 +165,7 @@ Deno.test("isParametersOf", async (t) => { const a: unknown = [0, "a"]; if (isParametersOf(predTup, predRest)(a)) { assertType< - Equal< + IsExact< typeof a, [ number | undefined, diff --git a/is/partial_of_test.ts b/is/partial_of_test.ts index 400d624..ee9a140 100644 --- a/is/partial_of_test.ts +++ b/is/partial_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { as } from "../as/mod.ts"; import { is } from "./mod.ts"; import { isPartialOf } from "./partial_of.ts"; @@ -40,7 +39,7 @@ Deno.test("isPartialOf", async (t) => { const a: unknown = { a: 0, b: "a", c: true }; if (isPartialOf(pred)(a)) { assertType< - Equal< + IsExact< typeof a, Partial< { @@ -92,7 +91,7 @@ Deno.test("isPartialOf", async (t) => { const a: unknown = { a: 0, [b]: "a", [c]: true }; if (isPartialOf(pred)(a)) { assertType< - Equal< + IsExact< typeof a, Partial<{ a: number; diff --git a/is/pick_of_test.ts b/is/pick_of_test.ts index 238a617..f295e43 100644 --- a/is/pick_of_test.ts +++ b/is/pick_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isPickOf } from "./pick_of.ts"; @@ -42,12 +41,12 @@ Deno.test("isPickOf", async (t) => { const a: unknown = { a: 0, b: "a", c: true }; if (isPickOf(pred, ["a", "c"])(a)) { assertType< - Equal + IsExact >(true); } if (isPickOf(isPickOf(pred, ["a", "c"]), ["a"])(a)) { assertType< - Equal + IsExact >(true); } }); @@ -91,12 +90,12 @@ Deno.test("isPickOf", async (t) => { const a: unknown = { a: 0, [b]: "a", [c]: true }; if (isPickOf(pred, ["a", c])(a)) { assertType< - Equal + IsExact >(true); } if (isPickOf(isPickOf(pred, ["a", c]), ["a"])(a)) { assertType< - Equal + IsExact >(true); } }); diff --git a/is/readonly_of_test.ts b/is/readonly_of_test.ts index 007dcfa..b7ff112 100644 --- a/is/readonly_of_test.ts +++ b/is/readonly_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { as } from "../as/mod.ts"; import { is } from "../is/mod.ts"; import { isReadonlyOf } from "./readonly_of.ts"; @@ -38,7 +37,7 @@ Deno.test("isReadonlyOf", async (t) => { const a: unknown = { a: 0, b: "a", c: true }; if (isReadonlyOf(pred)(a)) { assertType< - Equal< + IsExact< typeof a, Readonly> > @@ -82,7 +81,7 @@ Deno.test("isReadonlyOf", async (t) => { const a: unknown = { a: 0, b: "a", c: true }; if (isReadonlyOf(pred)(a)) { assertType< - Equal< + IsExact< typeof a, Readonly<{ a: number; b: string | undefined; c: boolean }> > @@ -122,7 +121,7 @@ Deno.test("isReadonlyOf", async (t) => { const a: unknown = []; if (isReadonlyOf(pred)(a)) { assertType< - Equal< + IsExact< typeof a, Readonly<[number, string, boolean]> > @@ -162,7 +161,7 @@ Deno.test("isReadonlyOf", async (t) => { const a: unknown = []; if (isReadonlyOf(pred)(a)) { assertType< - Equal< + IsExact< typeof a, Readonly<[number, number, number]> > @@ -209,7 +208,7 @@ Deno.test("isReadonlyOf", async (t) => { const a: unknown = { a: 0, [b]: "a", [c]: true }; if (isReadonlyOf(pred)(a)) { assertType< - Equal< + IsExact< typeof a, Readonly<{ a: number; [b]: string | undefined; [c]: boolean }> > diff --git a/is/record_object_of_test.ts b/is/record_object_of_test.ts index ba9f7ba..e434347 100644 --- a/is/record_object_of_test.ts +++ b/is/record_object_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isRecordObjectOf } from "./record_object_of.ts"; @@ -27,7 +26,7 @@ Deno.test("isRecordObjectOf", async (t) => { await t.step("predicated type is correct", () => { const a: unknown = { a: 0 }; if (isRecordObjectOf(is.Number)(a)) { - assertType>>(true); + assertType>>(true); } }); @@ -105,7 +104,7 @@ Deno.test("isRecordObjectOf", async (t) => { await t.step("predicated type is correct", () => { const a: unknown = { a: 0 }; if (isRecordObjectOf(is.Number, is.String)(a)) { - assertType>>(true); + assertType>>(true); } }); @@ -192,7 +191,7 @@ Deno.test("isRecordObjectOf", async (t) => { await t.step("predicated type is correct", () => { const a: unknown = { a: 0 }; if (isRecordObjectOf(is.Number, is.Symbol)(a)) { - assertType>>(true); + assertType>>(true); } }); }); diff --git a/is/record_of_test.ts b/is/record_of_test.ts index 81d68f7..90acd01 100644 --- a/is/record_of_test.ts +++ b/is/record_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isRecordOf } from "./record_of.ts"; @@ -27,7 +26,7 @@ Deno.test("isRecordOf", async (t) => { await t.step("predicated type is correct", () => { const a: unknown = { a: 0 }; if (isRecordOf(is.Number)(a)) { - assertType>>(true); + assertType>>(true); } }); @@ -101,7 +100,7 @@ Deno.test("isRecordOf", async (t) => { await t.step("predicated type is correct", () => { const a: unknown = { a: 0 }; if (isRecordOf(is.Number, is.String)(a)) { - assertType>>(true); + assertType>>(true); } }); @@ -179,7 +178,7 @@ Deno.test("isRecordOf", async (t) => { await t.step("predicated type is correct", () => { const a: unknown = { a: 0 }; if (isRecordOf(is.Number, is.Symbol)(a)) { - assertType>>(true); + assertType>>(true); } }); }); diff --git a/is/required_of_test.ts b/is/required_of_test.ts index a460130..a36b821 100644 --- a/is/required_of_test.ts +++ b/is/required_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { as } from "../as/mod.ts"; import { is } from "./mod.ts"; import { isRequiredOf } from "./required_of.ts"; @@ -50,7 +49,7 @@ Deno.test("isRequiredOf", async (t) => { const a: unknown = { a: 0, b: "a", c: true }; if (isRequiredOf(pred)(a)) { assertType< - Equal< + IsExact< typeof a, { a: number; @@ -113,7 +112,7 @@ Deno.test("isRequiredOf", async (t) => { const a: unknown = { a: 0, [b]: "a", [c]: true }; if (isRequiredOf(pred)(a)) { assertType< - Equal< + IsExact< typeof a, { a: number; diff --git a/is/set_of_test.ts b/is/set_of_test.ts index b009562..658770e 100644 --- a/is/set_of_test.ts +++ b/is/set_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isSetOf } from "./set_of.ts"; @@ -27,7 +26,7 @@ Deno.test("isSetOf", async (t) => { await t.step("predicated type is correct", () => { const a: unknown = new Set([0, 1, 2]); if (isSetOf(is.Number)(a)) { - assertType>>(true); + assertType>>(true); } }); }); diff --git a/is/strict_of_test.ts b/is/strict_of_test.ts index d8f5b11..5d1c1ea 100644 --- a/is/strict_of_test.ts +++ b/is/strict_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { as } from "../as/mod.ts"; import { is } from "./mod.ts"; import { isStrictOf } from "./strict_of.ts"; @@ -77,7 +76,7 @@ Deno.test("isStrictOf", async (t) => { }; const a: unknown = { a: 0, b: "a", c: true }; if (isStrictOf(is.ObjectOf(predObj))(a)) { - assertType>(true); + assertType>(true); } }); @@ -150,7 +149,7 @@ Deno.test("isStrictOf", async (t) => { const a: unknown = { a: 0, b: "a" }; if (isStrictOf(is.ObjectOf(predObj))(a)) { assertType< - Equal< + IsExact< typeof a, { a: number; b: string | undefined; c?: boolean | undefined } > @@ -261,7 +260,7 @@ Deno.test("isStrictOf", async (t) => { const a: unknown = { a: 0, [b]: "a" }; if (isStrictOf(is.ObjectOf(predObj))(a)) { assertType< - Equal< + IsExact< typeof a, { a: number; [b]: string | undefined; [c]?: boolean | undefined } > diff --git a/is/tuple_of_test.ts b/is/tuple_of_test.ts index b6bc7f5..d66ffb7 100644 --- a/is/tuple_of_test.ts +++ b/is/tuple_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isTupleOf } from "./tuple_of.ts"; @@ -41,7 +40,7 @@ Deno.test("isTupleOf", async (t) => { const predTup = [is.Number, is.String, is.Boolean] as const; const a: unknown = [0, "a", true]; if (isTupleOf(predTup)(a)) { - assertType>(true); + assertType>(true); } }); }); @@ -118,7 +117,7 @@ Deno.test("isTupleOf", async (t) => { const predRest = is.ArrayOf(is.Number); const a: unknown = [0, "a", true, 0, 1, 2]; if (isTupleOf(predTup, predRest)(a)) { - assertType>( + assertType>( true, ); } @@ -197,7 +196,7 @@ Deno.test("isTupleOf", async (t) => { const predTup = [is.Number, is.String, is.Boolean] as const; const a: unknown = [0, 1, 2, 0, "a", true]; if (isTupleOf(predRest, predTup)(a)) { - assertType>( + assertType>( true, ); } @@ -321,7 +320,7 @@ Deno.test("isTupleOf", async (t) => { const a: unknown = [0, "a", true, 0, 1, 2, 0, true]; if (isTupleOf(predTup, predRest, predTrail)(a)) { assertType< - Equal< + IsExact< typeof a, [number, string, boolean, ...number[], number, boolean] > diff --git a/is/uniform_tuple_of_test.ts b/is/uniform_tuple_of_test.ts index 3b4574f..b1e53e5 100644 --- a/is/uniform_tuple_of_test.ts +++ b/is/uniform_tuple_of_test.ts @@ -1,7 +1,6 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import type { Equal } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; import { is } from "./mod.ts"; import { isUniformTupleOf } from "./uniform_tuple_of.ts"; @@ -30,12 +29,12 @@ Deno.test("isUniformTupleOf", async (t) => { const a: unknown = [0, 1, 2, 3, 4]; if (isUniformTupleOf(5)(a)) { assertType< - Equal + IsExact >(true); } if (isUniformTupleOf(5, is.Number)(a)) { - assertType>( + assertType>( true, ); } diff --git a/is/union_of_test.ts b/is/union_of_test.ts index 8d54953..0128e0a 100644 --- a/is/union_of_test.ts +++ b/is/union_of_test.ts @@ -1,7 +1,7 @@ import { assertEquals } from "@std/assert"; import { assertSnapshot } from "@std/testing/snapshot"; -import { assertType } from "@std/testing/types"; -import { type Equal, testWithExamples } from "../_testutil.ts"; +import { assertType, type IsExact } from "@std/testing/types"; +import { testWithExamples } from "../_testutil.ts"; import type { PredicateType } from "../type.ts"; import { is } from "./mod.ts"; import { isUnionOf } from "./union_of.ts"; @@ -29,7 +29,7 @@ Deno.test("isUnionOf", async (t) => { const preds = [is.Number, is.String, is.Boolean] as const; const a: unknown = [0, "a", true]; if (isUnionOf(preds)(a)) { - assertType>(true); + assertType>(true); } }); @@ -41,7 +41,7 @@ Deno.test("isUnionOf", async (t) => { const preds = [isFoo, isBar] as const; const a: unknown = [0, "a", true]; if (isUnionOf(preds)(a)) { - assertType>(true); + assertType>(true); } }); });