diff --git a/is.ts b/is.ts index 5f19c28..4430ee4 100644 --- a/is.ts +++ b/is.ts @@ -18,6 +18,13 @@ export function isAny(_x: unknown): _x is any { return true; } +/** + * Always return `true` regardless of the type of `x`. + */ +export function isUnknown(_x: unknown): _x is unknown { + return true; +} + /** * Return `true` if the type of `x` is `string`. */ @@ -508,6 +515,7 @@ export function isOptionalOf( export default { Any: isAny, + Unknown: isUnknown, String: isString, Number: isNumber, BigInt: isBigInt, diff --git a/is_test.ts b/is_test.ts index dadfbcf..e119a3b 100644 --- a/is_test.ts +++ b/is_test.ts @@ -36,6 +36,7 @@ import is, { isTupleOf, isUndefined, isUniformTupleOf, + isUnknown, Predicate, PredicateType, } from "./is.ts"; @@ -135,6 +136,26 @@ Deno.test("isAny", async (t) => { }); }); +Deno.test("isUnknown", async (t) => { + await testWithExamples(t, isUnknown, { + validExamples: [ + "string", + "number", + "bigint", + "boolean", + "array", + "record", + "syncFunction", + "asyncFunction", + "null", + "undefined", + "symbol", + "date", + "promise", + ], + }); +}); + Deno.test("isString", async (t) => { await testWithExamples(t, isString, { validExamples: ["string"] }); });