Socket
Socket
Sign inDemoInstall

type-fest

Package Overview
Dependencies
0
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.9.0 to 4.10.0

2

package.json
{
"name": "type-fest",
"version": "4.9.0",
"version": "4.10.0",
"description": "A collection of essential TypeScript types",

@@ -5,0 +5,0 @@ "license": "(MIT OR CC0-1.0)",

import type {DelimiterCase} from './delimiter-case';
import type {NonRecursiveType} from './internal';
import type {UnknownArray} from './unknown-array';

@@ -51,3 +52,3 @@

Delimiter extends string,
> = Value extends Function | Date | RegExp
> = Value extends NonRecursiveType
? Value

@@ -54,0 +55,0 @@ : Value extends UnknownArray

@@ -20,3 +20,3 @@ import type {StringDigit} from '../source/internal';

type GetWithPath<BaseType, Keys extends readonly string[], Options extends GetOptions = {}> =
Keys extends []
Keys extends readonly []
? BaseType

@@ -129,3 +129,3 @@ : Keys extends readonly [infer Head, ...infer Tail]

? StrictPropertyOf<BaseType, Key, Options>
: BaseType extends [] | [unknown, ...unknown[]]
: BaseType extends readonly [] | readonly [unknown, ...unknown[]]
? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.

@@ -132,0 +132,0 @@ : BaseType extends {

@@ -439,1 +439,36 @@ import type {Primitive} from './primitive';

: InternalUnionMax<N, [...T, unknown]>;
/**
Returns a boolean for whether the given type is a union type.
@example
```
type A = IsUnion<string | number>;
//=> true
type B = IsUnion<string>;
//=> false
```
*/
export type IsUnion<T> = InternalIsUnion<T>;
/**
The actual implementation of `IsUnion`.
*/
type InternalIsUnion<T, U = T> =
(
// @link https://ghaiklor.github.io/type-challenges-solutions/en/medium-isunion.html
IsNever<T> extends true
? false
: T extends any
? [U] extends [T]
? false
: true
: never
) extends infer Result
// In some cases `Result` will return `false | true` which is `boolean`,
// that means `T` has at least two types and it's a union type,
// so we will return `true` instead of `boolean`.
? boolean extends Result ? true
: Result
: never; // Should never happen
import type {OmitIndexSignature} from './omit-index-signature';
import type {PickIndexSignature} from './pick-index-signature';
import type {EnforceOptional} from './enforce-optional';
import type {Simplify} from './simplify';

@@ -44,4 +44,6 @@ // Merges two objects without worrying about index signatures.

*/
export type Merge<Destination, Source> = EnforceOptional<
export type Merge<Destination, Source> =
Simplify<
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
>;

@@ -1,2 +0,2 @@

import type {NonRecursiveType, UnionMin, UnionMax, TupleLength, StaticPartOfArray, VariablePartOfArray} from './internal';
import type {NonRecursiveType, UnionMin, UnionMax, TupleLength, StaticPartOfArray, VariablePartOfArray, IsUnion} from './internal';
import type {IsNever} from './is-never';

@@ -111,6 +111,9 @@ import type {UnknownArray} from './unknown-array';

export type SharedUnionFieldsDeep<Union, Options extends SharedUnionFieldsDeepOptions = {recurseIntoArrays: false}> =
// If `Union` is not a union type, return `Union` directly.
IsUnion<Union> extends false
? Union
// `Union extends` will convert `Union`
// to a [distributive conditionaltype](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
// But this is not what we want, so we need to wrap `Union` with `[]` to prevent it.
[Union] extends [NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown>]
: [Union] extends [NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown>]
? Union

@@ -117,0 +120,0 @@ : [Union] extends [UnknownArray]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc