File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,14 @@ export type Predicate<T> = (x: unknown) => x is T;
88 */
99export type PredicateType < P > = P extends Predicate < infer T > ? T : never ;
1010
11+ /**
12+ * Always return `true` regardless of the type of `x`.
13+ */
14+ // deno-lint-ignore no-explicit-any
15+ export function isAny ( _x : unknown ) : _x is any {
16+ return true ;
17+ }
18+
1119/**
1220 * Return `true` if the type of `x` is `string`.
1321 */
@@ -404,6 +412,7 @@ export function isOptionalOf<T>(
404412}
405413
406414export default {
415+ Any : isAny ,
407416 String : isString ,
408417 Number : isNumber ,
409418 BigInt : isBigInt ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type {
88} from "https://deno.land/[email protected] /testing/types.ts" ; 99import is , {
1010 isAllOf ,
11+ isAny ,
1112 isArray ,
1213 isArrayOf ,
1314 isBigInt ,
@@ -108,6 +109,25 @@ Deno.test("PredicateType", () => {
108109 > ;
109110} ) ;
110111
112+ Deno . test ( "isAny" , async ( t ) => {
113+ await testWithExamples ( t , isAny , {
114+ validExamples : [
115+ "string" ,
116+ "number" ,
117+ "bigint" ,
118+ "boolean" ,
119+ "array" ,
120+ "record" ,
121+ "function" ,
122+ "null" ,
123+ "undefined" ,
124+ "symbol" ,
125+ "date" ,
126+ "promise" ,
127+ ] ,
128+ } ) ;
129+ } ) ;
130+
111131Deno . test ( "isString" , async ( t ) => {
112132 await testWithExamples ( t , isString , { validExamples : [ "string" ] } ) ;
113133} ) ;
You can’t perform that action at this time.
0 commit comments