inferred-types 0.53.2 → 0.53.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9220,21 +9220,6 @@ type AsNarrowingFn<TParams extends Tuple | TypedFunction, TReturn = unknown, TPr
9220
9220
  */
9221
9221
  type RemoveFnProps<T extends AnyFunction> = (...args: AsFnMeta<T>["args"]) => AsFnMeta<T>["returns"];
9222
9222
 
9223
- /**
9224
- * **ToFn**`<T>`
9225
- *
9226
- * Ensures that resultant type is a function, where the mapping is:
9227
- *
9228
- * - `AnyFunction` - function signature maintained
9229
- * - `FnMeta` - is converted to a precise function type
9230
- * - `never` _or_ `ErrorCondition` - returned "as is"
9231
- *
9232
- * All other values will return a function of the form `() => T`
9233
- *
9234
- * **Related:** `AsFn`
9235
- */
9236
- type ToFn<T> = T extends AnyFunction ? T : T extends FnMeta<infer _Args, infer _Returns, infer Props, infer Fn> ? IsNever<Props> extends true ? Fn : Fn & Props : () => T;
9237
-
9238
9223
  /**
9239
9224
  * **TypeGuard**
9240
9225
  *
@@ -13388,9 +13373,14 @@ declare function isFalsy<V extends Narrowable>(val: V): val is V & FalsyValue;
13388
13373
  * **isFnWithDict**(input)
13389
13374
  *
13390
13375
  * Type guard which checks whether a give variable is a function
13391
- * which _also_ contains
13376
+ * which contains at least one parameter.
13377
+ *
13378
+ * - if you set the parameter types, it will check that precisely the
13379
+ * correct amount are set
13392
13380
  */
13393
- declare function isFnWithParams<T>(input: T): input is Exclude<T, Scalar | undefined> & ToFn<Exclude<T, Scalar | undefined>>;
13381
+ declare function isFnWithParams<T, P extends readonly SimpleToken[]>(input: T, ...params: P): input is T & AsNarrowingFn<P["length"] extends 0 ? [any, ...any[]] : {
13382
+ [K in keyof P]: SimpleType<P[K]>;
13383
+ }, T extends TypedFunction ? ReturnType<T> : unknown>;
13394
13384
 
13395
13385
  /**
13396
13386
  * **isFunction**(value)
@@ -9220,21 +9220,6 @@ type AsNarrowingFn<TParams extends Tuple | TypedFunction, TReturn = unknown, TPr
9220
9220
  */
9221
9221
  type RemoveFnProps<T extends AnyFunction> = (...args: AsFnMeta<T>["args"]) => AsFnMeta<T>["returns"];
9222
9222
 
9223
- /**
9224
- * **ToFn**`<T>`
9225
- *
9226
- * Ensures that resultant type is a function, where the mapping is:
9227
- *
9228
- * - `AnyFunction` - function signature maintained
9229
- * - `FnMeta` - is converted to a precise function type
9230
- * - `never` _or_ `ErrorCondition` - returned "as is"
9231
- *
9232
- * All other values will return a function of the form `() => T`
9233
- *
9234
- * **Related:** `AsFn`
9235
- */
9236
- type ToFn<T> = T extends AnyFunction ? T : T extends FnMeta<infer _Args, infer _Returns, infer Props, infer Fn> ? IsNever<Props> extends true ? Fn : Fn & Props : () => T;
9237
-
9238
9223
  /**
9239
9224
  * **TypeGuard**
9240
9225
  *
@@ -13388,9 +13373,14 @@ declare function isFalsy<V extends Narrowable>(val: V): val is V & FalsyValue;
13388
13373
  * **isFnWithDict**(input)
13389
13374
  *
13390
13375
  * Type guard which checks whether a give variable is a function
13391
- * which _also_ contains
13376
+ * which contains at least one parameter.
13377
+ *
13378
+ * - if you set the parameter types, it will check that precisely the
13379
+ * correct amount are set
13392
13380
  */
13393
- declare function isFnWithParams<T>(input: T): input is Exclude<T, Scalar | undefined> & ToFn<Exclude<T, Scalar | undefined>>;
13381
+ declare function isFnWithParams<T, P extends readonly SimpleToken[]>(input: T, ...params: P): input is T & AsNarrowingFn<P["length"] extends 0 ? [any, ...any[]] : {
13382
+ [K in keyof P]: SimpleType<P[K]>;
13383
+ }, T extends TypedFunction ? ReturnType<T> : unknown>;
13394
13384
 
13395
13385
  /**
13396
13386
  * **isFunction**(value)
@@ -2861,8 +2861,8 @@ function isFalsy(val) {
2861
2861
  }
2862
2862
 
2863
2863
  // src/type-guards/isFnWithParams.ts
2864
- function isFnWithParams(input) {
2865
- return typeof input === "function" && Object.keys(input)?.length > 0;
2864
+ function isFnWithParams(input, ...params) {
2865
+ return params.length === 0 ? typeof input === "function" && input?.length > 0 : typeof input === "function" && input?.length === params.length;
2866
2866
  }
2867
2867
 
2868
2868
  // src/type-guards/isHexadecimal.ts