type-fest
Advanced tools
Comparing version 4.17.0 to 4.18.0
{ | ||
"name": "type-fest", | ||
"version": "4.17.0", | ||
"version": "4.18.0", | ||
"description": "A collection of essential TypeScript types", | ||
@@ -42,6 +42,6 @@ "license": "(MIT OR CC0-1.0)", | ||
"devDependencies": { | ||
"expect-type": "^0.15.0", | ||
"expect-type": "^0.19.0", | ||
"npm-run-all2": "^6.1.2", | ||
"tsd": "^0.31.0", | ||
"typescript": "~5.4.3", | ||
"typescript": "~5.4.5", | ||
"xo": "^0.58.0" | ||
@@ -48,0 +48,0 @@ }, |
@@ -154,6 +154,4 @@ <div align="center"> | ||
- [`LiteralUnion`](source/literal-union.d.ts) - Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union. Workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). | ||
- [`Tagged`](source/opaque.d.ts) - Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) if needed. | ||
- [`UnwrapTagged`](source/opaque.d.ts) - Get the untagged portion of a tagged type created with `Tagged`. | ||
- [`Opaque`](source/opaque.d.ts) - Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d). This implementation only supports a single tag. | ||
- [`UnwrapOpaque`](source/opaque.d.ts) - Get the untagged portion of a tagged type created with `Opaque` or `Tagged`. | ||
- [`Tagged`](source/opaque.d.ts) - Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) and [per-tag metadata](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf). (This replaces the previous [`Opaque`](source/opaque.d.ts) type, which is now deprecated.) | ||
- [`UnwrapTagged`](source/opaque.d.ts) - Get the untagged portion of a tagged type created with `Tagged`. (This replaces the previous [`UnwrapOpaque`](source/opaque.d.ts) type, which is now deprecated.) | ||
- [`InvariantOf`](source/invariant-of.d.ts) - Create an [invariant type](https://basarat.gitbook.io/typescript/type-system/type-compatibility#footnote-invariance), which is a type that does not accept supertypes and subtypes. | ||
@@ -204,2 +202,4 @@ - [`SetOptional`](source/set-optional.d.ts) - Create a type that makes the given keys optional. | ||
- [`DistributedPick`](source/distributed-pick.d.ts) - Picks keys from a type, distributing the operation over a union. | ||
- [`And`](source/and.d.ts) - Returns a boolean for whether two given types are both true. | ||
- [`Or`](source/or.d.ts) - Returns a boolean for whether either of two given types are true. | ||
@@ -350,3 +350,4 @@ ### Type Guard | ||
- `AllKeys` - See [`KeysOfUnion`](source/keys-of-union.d.ts) | ||
- `Branded` - See [`Opaque`](source/opaque.d.ts) | ||
- `Branded` - See [`Tagged`](source/opaque.d.ts) | ||
- `Opaque` - See [`Tagged`](source/opaque.d.ts) | ||
@@ -353,0 +354,0 @@ ## Tips |
@@ -6,4 +6,5 @@ import type {Sum} from './sum'; | ||
import type {IsNegative} from './numeric'; | ||
import type {And, Not, ArrayMin} from './internal'; | ||
import type {Not, ArrayMin} from './internal'; | ||
import type {IsEqual} from './is-equal'; | ||
import type {And} from './and'; | ||
import type {ArraySplice} from './array-splice'; | ||
@@ -10,0 +11,0 @@ |
@@ -1,4 +0,6 @@ | ||
import type {NumberAbsolute, And, Or, PositiveNumericStringGt} from './internal'; | ||
import type {NumberAbsolute, PositiveNumericStringGt} from './internal'; | ||
import type {IsEqual} from './is-equal'; | ||
import type {PositiveInfinity, NegativeInfinity, IsNegative} from './numeric'; | ||
import type {And} from './and'; | ||
import type {Or} from './or'; | ||
@@ -5,0 +7,0 @@ /** |
@@ -455,38 +455,2 @@ import type {Primitive} from './primitive'; | ||
/** | ||
Returns a boolean for whether A and B are both true. | ||
@example | ||
``` | ||
And<true, true>; | ||
//=> true | ||
And<true, false>; | ||
//=> false | ||
``` | ||
*/ | ||
export type And<A extends boolean, B extends boolean> = [A, B][number] extends true | ||
? true | ||
: true extends [IsEqual<A, false>, IsEqual<B, false>][number] | ||
? false | ||
: never; | ||
/** | ||
Returns a boolean for either A or B is true. | ||
@example | ||
``` | ||
Or<true, false>; | ||
//=> true | ||
Or<false, false>; | ||
//=> false | ||
``` | ||
*/ | ||
export type Or<A extends boolean, B extends boolean> = [A, B][number] extends false | ||
? false | ||
: true extends [IsEqual<A, true>, IsEqual<B, true>][number] | ||
? true | ||
: never; | ||
/** | ||
Returns a boolean for whether A is false. | ||
@@ -493,0 +457,0 @@ |
@@ -12,11 +12,4 @@ /** | ||
``` | ||
import type {IsNever} from 'type-fest'; | ||
import type {IsNever, And} from 'type-fest'; | ||
type And<A, B> = | ||
A extends true | ||
? B extends true | ||
? true | ||
: false | ||
: false; | ||
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts | ||
@@ -23,0 +16,0 @@ type AreStringsEqual<A extends string, B extends string> = |
@@ -79,2 +79,3 @@ declare const tag: unique symbol; | ||
@category Type | ||
@deprecated Use {@link Tagged} instead | ||
*/ | ||
@@ -113,2 +114,3 @@ export type Opaque<Type, Token = unknown> = Type & TagContainer<Token>; | ||
@category Type | ||
@deprecated Use {@link UnwrapTagged} instead | ||
*/ | ||
@@ -115,0 +117,0 @@ export type UnwrapOpaque<OpaqueType extends TagContainer<unknown>> = |
@@ -1,2 +0,2 @@ | ||
import type {NumberAbsolute, BuildTuple, And, Or} from './internal'; | ||
import type {NumberAbsolute, BuildTuple} from './internal'; | ||
import type {IsEqual} from './is-equal'; | ||
@@ -6,2 +6,4 @@ import type {PositiveInfinity, NegativeInfinity, IsNegative} from './numeric'; | ||
import type {Sum} from './sum'; | ||
import type {And} from './and'; | ||
import type {Or} from './or'; | ||
@@ -8,0 +10,0 @@ /** |
@@ -1,5 +0,7 @@ | ||
import type {NumberAbsolute, BuildTuple, And, Or, ArrayMax, ArrayMin} from './internal'; | ||
import type {NumberAbsolute, BuildTuple, ArrayMax, ArrayMin} from './internal'; | ||
import type {IsEqual} from './is-equal'; | ||
import type {PositiveInfinity, NegativeInfinity, IsNegative} from './numeric'; | ||
import type {Subtract} from './subtract'; | ||
import type {And} from './and'; | ||
import type {Or} from './or'; | ||
@@ -6,0 +8,0 @@ /** |
@@ -22,2 +22,3 @@ declare namespace TsConfigJson { | ||
| 'NodeNext' | ||
| 'Preserve' | ||
| 'None' | ||
@@ -36,2 +37,3 @@ // Lowercase alternatives | ||
| 'nodenext' | ||
| 'preserve' | ||
| 'none'; | ||
@@ -118,2 +120,10 @@ | ||
| 'ES2021.WeakRef' | ||
| 'ES2022' | ||
| 'ES2022.Array' | ||
| 'ES2022.Error' | ||
| 'ES2022.Intl' | ||
| 'ES2022.Object' | ||
| 'ES2022.SharedMemory' | ||
| 'ES2022.String' | ||
| 'ES2022.RegExp' | ||
| 'ESNext' | ||
@@ -178,2 +188,10 @@ | 'ESNext.Array' | ||
| 'es2021.weakref' | ||
| 'es2022' | ||
| 'es2022.array' | ||
| 'es2022.error' | ||
| 'es2022.intl' | ||
| 'es2022.object' | ||
| 'es2022.sharedmemory' | ||
| 'es2022.string' | ||
| 'es2022.regexp' | ||
| 'esnext' | ||
@@ -180,0 +198,0 @@ | 'esnext.array' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
362977
141
8754
992