Socket
Socket
Sign inDemoInstall

type-fest

Package Overview
Dependencies
0
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.19.0 to 4.20.0

2

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

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

@@ -25,6 +25,8 @@ import type {Primitive} from './primitive';

IsNever<T> extends false // Must be wider than `never`
? [T] extends [LiteralType] // Must be narrower than `LiteralType`
? [LiteralType] extends [T] // Cannot be wider than `LiteralType`
? false
: true
? [T] extends [LiteralType & infer U] // Remove any branding
? [U] extends [LiteralType] // Must be narrower than `LiteralType`
? [LiteralType] extends [U] // Cannot be wider than `LiteralType`
? false
: true
: false
: false

@@ -31,0 +33,0 @@ : false

@@ -15,3 +15,6 @@ import type {ConditionalSimplifyDeep} from './conditional-simplify';

import type {SimplifyDeep} from './simplify-deep';
import type {UnknownArray} from './unknown-array';
type SimplifyDeepExcludeArray<T> = SimplifyDeep<T, UnknownArray>;
/**

@@ -251,3 +254,3 @@ Try to merge two record properties or return the source property value, preserving `undefined` properties values in both cases.

? Source[number] extends UnknownRecord
? Array<SimplifyDeep<MergeDeepRecord<Destination[number], Source[number], Options>>>
? Array<SimplifyDeepExcludeArray<MergeDeepRecord<Destination[number], Source[number], Options>>>
: DoMergeArrayOrTuple<Destination, Source, Options>

@@ -295,3 +298,3 @@ : DoMergeArrayOrTuple<Destination, Source, Options>;

Options extends MergeDeepInternalOptions,
> = SimplifyDeep<[undefined] extends [Destination | Source]
> = SimplifyDeepExcludeArray<[undefined] extends [Destination | Source]
? DefaultType

@@ -359,3 +362,3 @@ : Destination extends UnknownRecord

*/
type MergeDeepWithDefaultOptions<Destination, Source, Options extends MergeDeepOptions> = SimplifyDeep<
type MergeDeepWithDefaultOptions<Destination, Source, Options extends MergeDeepOptions> = SimplifyDeepExcludeArray<
[undefined] extends [Destination | Source]

@@ -484,5 +487,5 @@ ? never

export type MergeDeep<Destination, Source, Options extends MergeDeepOptions = {}> = MergeDeepWithDefaultOptions<
SimplifyDeep<Destination>,
SimplifyDeep<Source>,
SimplifyDeepExcludeArray<Destination>,
SimplifyDeepExcludeArray<Source>,
Options
>;

@@ -78,4 +78,4 @@ import type {ArraySplice} from './array-splice';

{[P in PathUnion]: OmitDeepWithOnePath<T, P>}[PathUnion]
>
>;
>,
UnknownArray>;

@@ -82,0 +82,0 @@ /**

import type {ConditionalSimplifyDeep} from './conditional-simplify';
import type {NonRecursiveType} from './internal';

@@ -6,2 +7,4 @@ /**

You can exclude certain types from being simplified by providing them in the second generic `ExcludeType`.
Useful to flatten the type output to improve type hints shown in editors.

@@ -13,8 +16,15 @@

type PositionX = {
left: number;
right: number;
};
type PositionY = {
top: number;
bottom: number;
};
type Properties1 = {
height: number;
position: {
top: number;
bottom: number;
};
position: PositionY;
};

@@ -24,6 +34,3 @@

width: number;
position: {
left: number;
right: number;
};
position: PositionX;
};

@@ -37,3 +44,3 @@

type SimplifyDeepProperties = SimplifyDeep<Properties1 & Properties2>;
// But if wrapped in SimplifyDeep, hovering over `Props` will show a flattened object with all the properties:
// But if wrapped in SimplifyDeep, hovering over `SimplifyDeepProperties` will show a flattened object with all the properties:
//

@@ -52,5 +59,62 @@ // SimplifyDeepProperties = {

@example
```
import type {SimplifyDeep} from 'type-fest';
// A complex type that you don't want or need to simplify
type ComplexType = {
a: string;
b: 'b';
c: number;
...
};
type PositionX = {
left: number;
right: number;
};
type PositionY = {
top: number;
bottom: number;
};
// You want to simplify all other types
type Properties1 = {
height: number;
position: PositionY;
foo: ComplexType;
};
type Properties2 = {
width: number;
position: PositionX;
foo: ComplexType;
};
type SimplifyDeepProperties = SimplifyDeep<Properties1 & Properties2, ComplexType>;
// If wrapped in `SimplifyDeep` and set `ComplexType` to exclude, hovering over `SimplifyDeepProperties` will
// show a flattened object with all the properties except `ComplexType`:
//
// SimplifyDeepProperties = {
// height: number;
// width: number;
// position: {
// top: number;
// bottom: number;
// left: number;
// right: number;
// };
// foo: ComplexType;
// };
```
@see Simplify
@category Object
*/
export type SimplifyDeep<Type> = ConditionalSimplifyDeep<Type, Function | Iterable<unknown>, object>;
export type SimplifyDeep<Type, ExcludeType = never> =
ConditionalSimplifyDeep<
Type,
ExcludeType | NonRecursiveType | Set<unknown> | Map<unknown, unknown>,
object
>;
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc