You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

type-fest

Package Overview
Dependencies
Maintainers
1
Versions
189
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-fest - npm Package Compare versions

Comparing version
5.4.2
to
5.4.3
+2
-2
package.json
{
"name": "type-fest",
"version": "5.4.2",
"version": "5.4.3",
"description": "A collection of essential TypeScript types",

@@ -30,3 +30,3 @@ "license": "(MIT OR CC0-1.0)",

"test:tsd": "node --max-old-space-size=6144 ./node_modules/.bin/tsd",
"test:xo": "node --max-old-space-size=6144 ./node_modules/.bin/xo",
"test:xo": "node --max-old-space-size=6144 ./node_modules/.bin/xo --ignores=lint-processors/fixtures/**/*.d.ts",
"test:linter": "node --test",

@@ -33,0 +33,0 @@ "test": "run-p test:*"

@@ -5,3 +5,3 @@ import type {IsNever} from '../is-never.d.ts';

import type {StringToNumber} from './string.d.ts';
import type {IsAnyOrNever} from './type.d.ts';
import type {IfNotAnyOrNever, IsAnyOrNever} from './type.d.ts';

@@ -48,6 +48,7 @@ /**

export type IsNumberLike<N> =
IsAnyOrNever<N> extends true ? N
: N extends number | `${number}`
IfNotAnyOrNever<N,
N extends number | `${number}`
? true
: false;
: false,
boolean, false>;

@@ -54,0 +55,0 @@ /**

import type {OmitIndexSignature} from './omit-index-signature.d.ts';
import type {PickIndexSignature} from './pick-index-signature.d.ts';
import type {Simplify} from './simplify.d.ts';
import type {If} from './if.d.ts';
import type {IsEqual} from './is-equal.d.ts';

@@ -50,9 +52,12 @@ // Merges two objects without worrying about index signatures.

? Source extends unknown // For distributing `Source`
? Simplify<
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
>
? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>>
: never // Should never happen
: never; // Should never happen
export type _Merge<Destination, Source> =
Simplify<
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
>;
export {};
import type {StaticPartOfArray, VariablePartOfArray, NonRecursiveType, ToString, IsNumberLike, ApplyDefaultOptions} from './internal/index.d.ts';
import type {IsAny} from './is-any.d.ts';
import type {UnknownArray} from './unknown-array.d.ts';
import type {Subtract} from './subtract.d.ts';
import type {GreaterThan} from './greater-than.d.ts';
import type {IsNever} from './is-never.d.ts';
import type {Sum} from './sum.d.ts';
import type {And} from './and.d.ts';

@@ -193,3 +194,3 @@ /**

type _Paths<T, Options extends Required<PathsOptions>> =
type _Paths<T, Options extends Required<PathsOptions>, CurrentDepth extends number = 0> =
T extends NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown>

@@ -202,9 +203,9 @@ ? never

// We need to handle the fixed and non-fixed index part of the array separately.
? InternalPaths<StaticPartOfArray<T>, Options> | InternalPaths<Array<VariablePartOfArray<T>[number]>, Options>
: InternalPaths<T, Options>
? InternalPaths<StaticPartOfArray<T>, Options, CurrentDepth> | InternalPaths<Array<VariablePartOfArray<T>[number]>, Options, CurrentDepth>
: InternalPaths<T, Options, CurrentDepth>
: T extends object
? InternalPaths<T, Options>
? InternalPaths<T, Options, CurrentDepth>
: never;
type InternalPaths<T, Options extends Required<PathsOptions>> =
type InternalPaths<T, Options extends Required<PathsOptions>, CurrentDepth extends number> =
Options['maxRecursionDepth'] extends infer MaxDepth extends number

@@ -220,10 +221,8 @@ ? Required<T> extends infer T

? (
Options['bracketNotation'] extends true
? IsNumberLike<Key> extends true
? `[${Key}]`
: (Key | ToString<Key>)
: Options['bracketNotation'] extends false
And<Options['bracketNotation'], IsNumberLike<Key>> extends true
? `[${Key}]`
// If `Key` is a number, return `Key | `${Key}``, because both `array[0]` and `array['0']` work.
? (Key | ToString<Key>)
: never
: CurrentDepth extends 0
? Key | ToString<Key>
: `.${(Key | ToString<Key>)}`
) extends infer TranformedKey extends string | number ?

@@ -233,3 +232,3 @@ // 1. If style is 'a[0].b' and 'Key' is a numberlike value like 3 or '3', transform 'Key' to `[${Key}]`, else to `${Key}` | Key

| ((Options['leavesOnly'] extends true
? MaxDepth extends 0
? MaxDepth extends CurrentDepth
? TranformedKey

@@ -245,5 +244,5 @@ : T[Key] extends infer Value

) extends infer _TransformedKey
// If `depth` is provided, the condition becomes truthy only when it reaches `0`.
// If `depth` is provided, the condition becomes truthy only when it reaches `CurrentDepth`.
// Otherwise, since `depth` defaults to `number`, the condition is always truthy, returning paths at all depths.
? 0 extends Options['depth']
? CurrentDepth extends Options['depth']
? _TransformedKey

@@ -254,24 +253,4 @@ : never

// Recursively generate paths for the current key
GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
? _Paths<T[Key],
{
bracketNotation: Options['bracketNotation'];
maxRecursionDepth: Subtract<MaxDepth, 1>;
leavesOnly: Options['leavesOnly'];
depth: Subtract<Options['depth'], 1>;
}> extends infer SubPath
? SubPath extends string | number
? (
Options['bracketNotation'] extends true
? SubPath extends `[${any}]` | `[${any}]${string}`
? `${TranformedKey}${SubPath}` // If next node is number key like `[3]`, no need to add `.` before it.
: `${TranformedKey}.${SubPath}`
: never
) | (
Options['bracketNotation'] extends false
? `${TranformedKey}.${SubPath}`
: never
)
: never
: never
GreaterThan<MaxDepth, CurrentDepth> extends true // Limit the depth to prevent infinite recursion
? `${TranformedKey}${_Paths<T[Key], Options, Sum<CurrentDepth, 1>> & (string | number)}`
: never

@@ -278,0 +257,0 @@ )