Socket
Socket
Sign inDemoInstall

type-fest

Package Overview
Dependencies
Maintainers
0
Versions
154
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 4.20.1 to 4.21.0

source/structured-cloneable.d.ts

1

index.d.ts

@@ -67,2 +67,3 @@ // Basic

export type {Jsonifiable} from './source/jsonifiable';
export type {StructuredCloneable} from './source/structured-cloneable';
export type {Schema} from './source/schema';

@@ -69,0 +70,0 @@ export type {LiteralToPrimitive} from './source/literal-to-primitive';

4

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

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

"tsd": "^0.31.0",
"typescript": "~5.4.5",
"typescript": "~5.5.3",
"xo": "^0.58.0"

@@ -48,0 +48,0 @@ },

@@ -170,3 +170,3 @@ <div align="center">

- [`Stringified`](source/stringified.d.ts) - Create a type with the keys of the given type changed to `string` type.
- [`IterableElement`](source/iterable-element.d.ts) - Get the element type of an `Iterable`/`AsyncIterable`. For example, an array or a generator.
- [`IterableElement`](source/iterable-element.d.ts) - Get the element type of an `Iterable`/`AsyncIterable`. For example, `Array`, `Set`, `Map`, generator, stream, etc.
- [`Entry`](source/entry.d.ts) - Create a type that represents the type of an entry of a collection.

@@ -253,2 +253,6 @@ - [`Entries`](source/entries.d.ts) - Create a type that represents the type of the entries of a collection.

### Structured clone
- [`StructuredCloneable`](source/structured-cloneable.d.ts) - Matches a value that can be losslessly cloned using `structuredClone`.
### Async

@@ -353,2 +357,5 @@

- `Opaque` - See [`Tagged`](source/opaque.d.ts)
- `SetElement` - See [`IterableElement`](source/iterable-element.d.ts)
- `SetEntry` - See [`IterableElement`](source/iterable-element.d.ts)
- `SetValues` - See [`IterableElement`](source/iterable-element.d.ts)

@@ -355,0 +362,0 @@ ## Tips

import type {CamelCase, CamelCaseOptions} from './camel-case';
import type {NonRecursiveType} from './internal';
import type {UnknownArray} from './unknown-array';

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

Options extends CamelCaseOptions = {preserveConsecutiveUppercase: true},
> = Value extends Function
> = Value extends NonRecursiveType
? Value

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

import type {ArrayElement, ObjectValue} from './internal';
import type {Opaque, TagContainer} from './opaque';
import type {IsEqual} from './is-equal';
import type {KeysOfUnion} from './keys-of-union';
import type {JsonObject} from './basic';

@@ -60,5 +60,4 @@ /**

: ParameterType extends readonly unknown[] ? ReadonlyArray<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>>
// Leave tagged types as-is. We could try to make the untagged part Exact, and just leave the tag as-is, but that seems to create instanitation excessively deep errors.
: ParameterType extends TagContainer<unknown> ? ParameterType
: ParameterType extends object ? ExactObject<ParameterType, InputType>
: ParameterType;
// Only apply Exact for pure object types. For types from a class, leave it unchanged to TypeScript to handle.
: ParameterType extends JsonObject ? ExactObject<ParameterType, InputType>
: ParameterType;

@@ -11,3 +11,3 @@ import type {BuildTuple} from './internal';

Note: `Start` or `End` must smaller than `1000`.
Note: `Start` or `End` must be non-negative and smaller than `1000`.

@@ -14,0 +14,0 @@ Use-cases:

/**
Get the element type of an `Iterable`/`AsyncIterable`. For example, an array or a generator.
Get the element type of an `Iterable`/`AsyncIterable`. For example, `Array`, `Set`, `Map`, generator, stream, etc.

@@ -36,3 +36,3 @@ This can be useful, for example, if you want to get the type that is yielded in a generator function. Often the return type of those functions are not specified.

Many types in JavaScript/TypeScript are iterables. This type works on all types that implement those interfaces. For example, `Array`, `Set`, `Map`, `stream.Readable`, etc.
Many types in JavaScript/TypeScript are iterables. This type works on all types that implement those interfaces.

@@ -48,2 +48,12 @@ An example with an array of strings:

@example
```
import type {IterableElement} from 'type-fest';
const fruits = new Set(['🍎', '🍌', 'πŸ‰'] as const);
type Fruit = IterableElement<typeof fruits>;
//=> '🍎' | '🍌' | 'πŸ‰'
```
@category Iterable

@@ -50,0 +60,0 @@ */

@@ -15,2 +15,3 @@ import type {JsonPrimitive, JsonValue} from './basic';

type NeverToNull<T> = IsNever<T> extends true ? null : T;
type UndefinedToNull<T> = T extends undefined ? null : T;

@@ -24,3 +25,3 @@ // Handles tuples and arrays

? []
: Array<T[number] extends NotJsonable ? null : Jsonify<T[number]>>;
: Array<T[number] extends NotJsonable ? null : Jsonify<UndefinedToNull<T[number]>>>;

@@ -27,0 +28,0 @@ type FilterJsonableKeys<T extends object> = {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc