type-fest
Advanced tools
| import type {UnknownArray} from './unknown-array.d.ts'; | ||
| /** | ||
| Extracts the element type of an array or tuple. | ||
| Use-cases: | ||
| - When you need type-safe element extraction that returns `never` for non-arrays. | ||
| - When extracting element types from generic array parameters in function signatures. | ||
| - For better readability and explicit intent over using `T[number]` directly. | ||
| Note: Returns `never` if the type is not an array. | ||
| @example | ||
| ``` | ||
| import type {ArrayElement} from 'type-fest'; | ||
| // Arrays | ||
| type StringArray = ArrayElement<string[]>; | ||
| //=> string | ||
| // Tuples | ||
| type Tuple = ArrayElement<[1, 2, 3]>; | ||
| //=> 1 | 2 | 3 | ||
| // Type-safe | ||
| type NotArray = ArrayElement<{a: string}>; | ||
| //=> never | ||
| // Practical example | ||
| declare function getRandomElement<T extends readonly unknown[]>(array: T): ArrayElement<T>; | ||
| getRandomElement(['foo', 'bar', 'baz'] as const); | ||
| //=> 'foo' | 'bar' | 'baz' | ||
| ``` | ||
| @see {@link ArrayValues} - For directly extracting values from a constant array type. | ||
| @see {@link IterableElement} - For iterables like `Set`, `Map`, and generators (not suitable for all use cases due to different inference behavior). | ||
| @category Array | ||
| */ | ||
| export type ArrayElement<T> = | ||
| T extends UnknownArray | ||
| ? T[number] | ||
| : never; | ||
| export {}; |
| import type {If} from './if.d.ts'; | ||
| import type {IfNotAnyOrNever, MapsSetsOrArrays, NonRecursiveType} from './internal/type.d.ts'; | ||
| import type {IsUnknown} from './is-unknown.d.ts'; | ||
| import type {KeysOfUnion} from './keys-of-union.d.ts'; | ||
| import type {Simplify} from './simplify.d.ts'; | ||
| /** | ||
| Ensure mutual exclusivity in object unions by adding other members’ keys as `?: never`. | ||
| Use-cases: | ||
| - You want each union member to be exclusive, preventing overlapping object shapes. | ||
| - You want to safely access any property defined across the union without additional type guards. | ||
| @example | ||
| ``` | ||
| import type {ExclusifyUnion} from 'type-fest'; | ||
| type FileConfig = { | ||
| filePath: string; | ||
| }; | ||
| type InlineConfig = { | ||
| content: string; | ||
| }; | ||
| declare function loadConfig1(options: FileConfig | InlineConfig): void; | ||
| // Someone could mistakenly provide both `filePath` and `content`. | ||
| loadConfig1({filePath: './config.json', content: '{ "name": "app" }'}); // No errors | ||
| // Use `ExclusifyUnion` to prevent that mistake. | ||
| type Config = ExclusifyUnion<FileConfig | InlineConfig>; | ||
| //=> {filePath: string; content?: never} | {content: string; filePath?: never} | ||
| declare function loadConfig2(options: Config): void; | ||
| // @ts-expect-error | ||
| loadConfig2({filePath: './config.json', content: '{ "name": "app" }'}); | ||
| //=> Error: Argument of type '{ filePath: string; content: string; }' is not assignable to parameter of type '{ filePath: string; content?: never; } | { content: string; filePath?: never; }'. | ||
| loadConfig2({filePath: './config.json'}); // Ok | ||
| loadConfig2({content: '{ "name": "app" }'}); // Ok | ||
| ``` | ||
| @example | ||
| ``` | ||
| import type {ExclusifyUnion} from 'type-fest'; | ||
| type CardPayment = { | ||
| amount: number; | ||
| cardNumber: string; | ||
| }; | ||
| type PaypalPayment = { | ||
| amount: number; | ||
| paypalId: string; | ||
| }; | ||
| function processPayment1(payment: CardPayment | PaypalPayment) { | ||
| // @ts-expect-error | ||
| const details = payment.cardNumber ?? payment.paypalId; // Cannot access `cardNumber` or `paypalId` directly | ||
| } | ||
| type Payment = ExclusifyUnion<CardPayment | PaypalPayment>; | ||
| //=> {amount: number; cardNumber: string; paypalId?: never} | {amount: number; paypalId: string; cardNumber?: never} | ||
| function processPayment2(payment: Payment) { | ||
| const details = payment.cardNumber ?? payment.paypalId; // Ok | ||
| //=> string | ||
| } | ||
| ``` | ||
| @example | ||
| ``` | ||
| import type {ExclusifyUnion} from 'type-fest'; | ||
| type A = ExclusifyUnion<{a: string} | {b: number}>; | ||
| //=> {a: string; b?: never} | {a?: never; b: number} | ||
| type B = ExclusifyUnion<{a: string} | {b: number} | {c: boolean}>; | ||
| //=> {a: string; b?: never; c?: never} | {a?: never; b: number; c?: never} | {a?: never; b?: never; c: boolean} | ||
| type C = ExclusifyUnion<{a: string; b: number} | {b: string; c: number}>; | ||
| //=> {a: string; b: number; c?: never} | {a?: never; b: string; c: number} | ||
| type D = ExclusifyUnion<{a?: 1; readonly b: 2} | {d: 4}>; | ||
| //=> {a?: 1; readonly b: 2; d?: never} | {a?: never; b?: never; d: 4} | ||
| ``` | ||
| @category Object | ||
| @category Union | ||
| */ | ||
| export type ExclusifyUnion<Union> = IfNotAnyOrNever<Union, | ||
| If<IsUnknown<Union>, Union, | ||
| Extract<Union, NonRecursiveType | MapsSetsOrArrays> extends infer SkippedMembers | ||
| ? SkippedMembers | _ExclusifyUnion<Exclude<Union, SkippedMembers>> | ||
| : never | ||
| > | ||
| >; | ||
| type _ExclusifyUnion<Union, UnionCopy = Union> = Union extends unknown // For distributing `Union` | ||
| ? Simplify< | ||
| Union & Partial< | ||
| Record< | ||
| Exclude<KeysOfUnion<UnionCopy>, keyof Union>, | ||
| never | ||
| > | ||
| > | ||
| > | ||
| : never; // Should never happen | ||
| export {}; |
+4
-0
@@ -144,2 +144,3 @@ // Basic | ||
| export type {ArrayTail} from './source/array-tail.d.ts'; | ||
| export type {ArrayElement} from './source/array-element.d.ts'; | ||
| export type {SetFieldType, SetFieldTypeOptions} from './source/set-field-type.d.ts'; | ||
@@ -166,2 +167,3 @@ export type {Paths, PathsOptions} from './source/paths.d.ts'; | ||
| export type {TupleOf} from './source/tuple-of.d.ts'; | ||
| export type {ExclusifyUnion} from './source/exclusify-union.d.ts'; | ||
@@ -207,1 +209,3 @@ // Template literal types | ||
| export type {ExcludeStrict} from './source/exclude-strict.d.ts'; | ||
| export {}; |
+3
-1
| { | ||
| "name": "type-fest", | ||
| "version": "5.1.0", | ||
| "version": "5.2.0", | ||
| "description": "A collection of essential TypeScript types", | ||
@@ -57,2 +57,4 @@ "license": "(MIT OR CC0-1.0)", | ||
| "@sindresorhus/tsconfig": "^8.0.1", | ||
| "@typescript-eslint/parser": "^8.44.0", | ||
| "eslint": "^9.35.0", | ||
| "expect-type": "^1.2.2", | ||
@@ -59,0 +61,0 @@ "npm-run-all2": "^8.0.4", |
+3
-1
@@ -182,3 +182,3 @@ <div align="center"> | ||
| - [`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. | ||
| - [`Or`](source/or.d.ts) - Returns a boolean for whether either of two given types is true. | ||
| - [`Xor`](source/xor.d.ts) - Returns a boolean for whether only one of two given types is true. | ||
@@ -192,2 +192,3 @@ - [`AllExtend`](source/all-extend.d.ts) - Returns a boolean for whether every element in an array type extends another type. | ||
| - [`ConditionalSimplifyDeep`](source/conditional-simplify-deep.d.ts) - Recursively simplifies a type while including and/or excluding certain types from being simplified. | ||
| - [`ExclusifyUnion`](source/exclusify-union.d.ts) - Ensure mutual exclusivity in object unions by adding other members’ keys as `?: never`. | ||
@@ -254,2 +255,3 @@ ### Type Guard | ||
| - [`ArraySlice`](source/array-slice.d.ts) - Returns an array slice of a given range, just like `Array#slice()`. | ||
| - [`ArrayElement`](source/array-element.d.ts) - Extracts the element type of an array or tuple. | ||
| - [`LastArrayElement`](source/last-array-element.d.ts) - Extract the type of the last element of an array. | ||
@@ -256,0 +258,0 @@ - [`FixedLengthArray`](source/fixed-length-array.d.ts) - Create a type that represents an array of the given type and length. The `Array` prototype methods that manipulate its length are excluded from the resulting type. |
@@ -65,3 +65,3 @@ import type {NonRecursiveType, ReadonlyKeysOfUnion, ValueOfUnion} from './internal/index.d.ts'; | ||
| @see SharedUnionFields | ||
| @see {@link SharedUnionFields} | ||
@@ -68,0 +68,0 @@ @category Object |
+2
-0
@@ -49,2 +49,3 @@ import type {AllExtend} from './all-extend.d.ts'; | ||
| Note: If either of the types is `never`, the result becomes `false`. | ||
| @example | ||
@@ -77,2 +78,3 @@ ``` | ||
| @see {@link Or} | ||
| @see {@link Xor} | ||
| */ | ||
@@ -79,0 +81,0 @@ export type And<A extends boolean, B extends boolean> = AllExtend<[A, B], true>; |
| /** | ||
| Create a type that represents either the value or an array of the value. | ||
| @see Promisable | ||
| @see {@link Promisable} | ||
@@ -6,0 +6,0 @@ @example |
| import type {ApplyDefaultOptions} from './internal/index.d.ts'; | ||
| import type {Words} from './words.d.ts'; | ||
| import type {Words, WordsOptions} from './words.d.ts'; | ||
@@ -9,3 +9,3 @@ /** | ||
| */ | ||
| export type CamelCaseOptions = { | ||
| export type CamelCaseOptions = WordsOptions & { | ||
| /** | ||
@@ -20,2 +20,3 @@ Whether to preserved consecutive uppercase letter. | ||
| export type _DefaultCamelCaseOptions = { | ||
| splitOnNumbers: true; | ||
| preserveConsecutiveUppercase: false; | ||
@@ -88,3 +89,3 @@ }; | ||
| : Uncapitalize<CamelCaseFromArray< | ||
| Words<Type extends Uppercase<Type> ? Lowercase<Type> : Type>, | ||
| Words<Type extends Uppercase<Type> ? Lowercase<Type> : Type, Options>, | ||
| ApplyDefaultOptions<CamelCaseOptions, _DefaultCamelCaseOptions, Options> | ||
@@ -91,0 +92,0 @@ >> |
@@ -10,4 +10,4 @@ import type {CamelCase, CamelCaseOptions, _DefaultCamelCaseOptions} from './camel-case.d.ts'; | ||
| @see CamelCasedProperties | ||
| @see CamelCase | ||
| @see {@link CamelCasedProperties} | ||
| @see {@link CamelCase} | ||
@@ -14,0 +14,0 @@ @example |
@@ -9,4 +9,4 @@ import type {CamelCase, CamelCaseOptions, _DefaultCamelCaseOptions} from './camel-case.d.ts'; | ||
| @see CamelCasedPropertiesDeep | ||
| @see CamelCase | ||
| @see {@link CamelCasedPropertiesDeep} | ||
| @see {@link CamelCase} | ||
@@ -13,0 +13,0 @@ @example |
@@ -25,3 +25,3 @@ import type {IsEqual} from './is-equal.d.ts'; | ||
| @see ConditionalPickDeep | ||
| @see {@link ConditionalPickDeep} | ||
| */ | ||
@@ -44,3 +44,3 @@ export type ConditionalPickDeepOptions = { | ||
| @see ConditionalPick | ||
| @see {@link ConditionalPick} | ||
@@ -47,0 +47,0 @@ @example |
@@ -64,3 +64,3 @@ /** | ||
| @see SimplifyDeep | ||
| @see {@link SimplifyDeep} | ||
| @category Object | ||
@@ -67,0 +67,0 @@ */ |
@@ -41,3 +41,3 @@ /** | ||
| @see ConditionalSimplifyDeep | ||
| @see {@link ConditionalSimplifyDeep} | ||
| @category Object | ||
@@ -44,0 +44,0 @@ */ |
@@ -30,4 +30,4 @@ import type {ApplyDefaultOptions, AsciiPunctuation, StartsWith} from './internal/index.d.ts'; | ||
| @see KebabCase | ||
| @see SnakeCase | ||
| @see {@link KebabCase} | ||
| @see {@link SnakeCase} | ||
@@ -34,0 +34,0 @@ @example |
@@ -11,4 +11,4 @@ import type {_DefaultDelimiterCaseOptions, DelimiterCase} from './delimiter-case.d.ts'; | ||
| @see DelimiterCase | ||
| @see DelimiterCasedProperties | ||
| @see {@link DelimiterCase} | ||
| @see {@link DelimiterCasedProperties} | ||
@@ -15,0 +15,0 @@ @example |
@@ -10,4 +10,4 @@ import type {_DefaultDelimiterCaseOptions, DelimiterCase} from './delimiter-case.d.ts'; | ||
| @see DelimiterCase | ||
| @see DelimiterCasedPropertiesDeep | ||
| @see {@link DelimiterCase} | ||
| @see {@link DelimiterCasedPropertiesDeep} | ||
@@ -14,0 +14,0 @@ @example |
@@ -43,3 +43,3 @@ declare const emptyObjectSymbol: unique symbol; | ||
| @see EmptyObject | ||
| @see {@link EmptyObject} | ||
| @category Object | ||
@@ -46,0 +46,0 @@ */ |
@@ -1,2 +0,3 @@ | ||
| import type {ArrayElement, ObjectValue} from './internal/index.d.ts'; | ||
| import type {ObjectValue} from './internal/index.d.ts'; | ||
| import type {ArrayElement} from './array-element.d.ts'; | ||
| import type {IsEqual} from './is-equal.d.ts'; | ||
@@ -3,0 +4,0 @@ import type {KeysOfUnion} from './keys-of-union.d.ts'; |
| import type {SplitOnRestElement} from './split-on-rest-element.d.ts'; | ||
| import type {IsArrayReadonly} from './internal/array.d.ts'; | ||
| import type {UnknownArray} from './unknown-array.d.ts'; | ||
| import type {IfNotAnyOrNever} from './internal/type.d.ts'; | ||
@@ -25,6 +26,7 @@ /** | ||
| @see ExtractRestElement, SplitOnRestElement | ||
| @see {@link ExtractRestElement} | ||
| @see {@link SplitOnRestElement} | ||
| @category Array | ||
| */ | ||
| export type ExcludeRestElement<Array_ extends UnknownArray> = | ||
| export type ExcludeRestElement<Array_ extends UnknownArray> = IfNotAnyOrNever<Array_, | ||
| SplitOnRestElement<Array_> extends infer Result | ||
@@ -35,5 +37,6 @@ ? Result extends readonly UnknownArray[] | ||
| : [...Result[0], ...Result[2]] | ||
| : Result | ||
| : never; | ||
| : never | ||
| : never | ||
| >; | ||
| export {}; |
@@ -24,3 +24,4 @@ import type {SplitOnRestElement} from './split-on-rest-element.d.ts'; | ||
| @see ExcludeRestElement, SplitOnRestElement | ||
| @see {@link ExcludeRestElement} | ||
| @see {@link SplitOnRestElement} | ||
| @category Array | ||
@@ -27,0 +28,0 @@ */ |
| /** | ||
| A stricter version of {@link Extract<T, U>} that ensures every member of `U` can successfully extract something from `T`. | ||
| For example, `StrictExtract<string | number | boolean, number | bigint>` will error because `bigint` cannot extract anything from `string | number | boolean`. | ||
| For example, `ExtractStrict<string | number | boolean, number | bigint>` will error because `bigint` cannot extract anything from `string | number | boolean`. | ||
@@ -6,0 +6,0 @@ @example |
@@ -22,4 +22,10 @@ import type {GreaterThan} from './greater-than.d.ts'; | ||
| ? never | ||
| : A extends B ? true : GreaterThan<A, B>; | ||
| : A extends number // For distributing `A` | ||
| ? B extends number // For distributing `B` | ||
| ? A extends B | ||
| ? true | ||
| : GreaterThan<A, B> | ||
| : never // Should never happen | ||
| : never; // Should never happen | ||
| export {}; |
+35
-0
@@ -57,2 +57,37 @@ import type {IsNever} from './is-never.d.ts'; | ||
| Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example: | ||
| @example | ||
| ``` | ||
| import type {If, IsEqual, StringRepeat} from 'type-fest'; | ||
| type HundredZeroes = StringRepeat<'0', 100>; | ||
| // The following implementation is not tail recursive | ||
| type Includes<S extends string, Char extends string> = | ||
| S extends `${infer First}${infer Rest}` | ||
| ? If<IsEqual<First, Char>, | ||
| 'found', | ||
| Includes<Rest, Char>> | ||
| : 'not found'; | ||
| // Hence, instantiations with long strings will fail | ||
| // @ts-expect-error | ||
| type Fails = Includes<HundredZeroes, '1'>; | ||
| // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| // Error: Type instantiation is excessively deep and possibly infinite. | ||
| // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive | ||
| type IncludesWithoutIf<S extends string, Char extends string> = | ||
| S extends `${infer First}${infer Rest}` | ||
| ? IsEqual<First, Char> extends true | ||
| ? 'found' | ||
| : IncludesWithoutIf<Rest, Char> | ||
| : 'not found'; | ||
| // Now, instantiations with long strings will work | ||
| type Works = IncludesWithoutIf<HundredZeroes, '1'>; | ||
| //=> 'not found' | ||
| ``` | ||
| @category Type Guard | ||
@@ -59,0 +94,0 @@ @category Utilities |
@@ -33,3 +33,3 @@ import type {IntRange} from './int-range.d.ts'; | ||
| @see IntRange | ||
| @see {@link IntRange} | ||
| */ | ||
@@ -36,0 +36,0 @@ export type IntClosedRange<Start extends number, End extends number, Skip extends number = 1> = IntRange<Start, Sum<End, 1>, Skip>; |
@@ -33,3 +33,3 @@ import type {TupleOf} from './tuple-of.d.ts'; | ||
| @see IntClosedRange | ||
| @see {@link IntClosedRange} | ||
| */ | ||
@@ -36,0 +36,0 @@ export type IntRange<Start extends number, End extends number, Step extends number = 1> = PrivateIntRange<Start, End, Step>; |
@@ -28,11 +28,2 @@ import type {If} from '../if.d.ts'; | ||
| /** | ||
| Extract the element of an array that also works for array union. | ||
| Returns `never` if T is not an array. | ||
| It creates a type-safe way to access the element type of `unknown` type. | ||
| */ | ||
| export type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never; | ||
| /** | ||
| Returns the static, fixed-length portion of the given array, excluding variable-length parts. | ||
@@ -39,0 +30,0 @@ |
@@ -5,2 +5,3 @@ import type {If} from '../if.d.ts'; | ||
| import type {Primitive} from '../primitive.d.ts'; | ||
| import type {UnknownArray} from '../unknown-array.d.ts'; | ||
@@ -18,2 +19,7 @@ /** | ||
| /** | ||
| Matches maps, sets, or arrays. | ||
| */ | ||
| export type MapsSetsOrArrays = ReadonlyMap<unknown, unknown> | WeakMap<WeakKey, unknown> | ReadonlySet<unknown> | WeakSet<WeakKey> | UnknownArray; | ||
| /** | ||
| Returns a boolean for whether the two given types extends the base type. | ||
@@ -101,2 +107,28 @@ */ | ||
| ``` | ||
| Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example: | ||
| @example | ||
| ```ts | ||
| import type {StringRepeat} from 'type-fest'; | ||
| type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>; | ||
| // The following implementation is not tail recursive | ||
| type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>; | ||
| // Hence, instantiations with long strings will fail | ||
| // @ts-expect-error | ||
| type T1 = TrimLeft<NineHundredNinetyNineSpaces>; | ||
| // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| // Error: Type instantiation is excessively deep and possibly infinite. | ||
| // To fix this, move the recursion into a helper type | ||
| type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>; | ||
| type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S; | ||
| type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>; | ||
| //=> '' | ||
| ``` | ||
| */ | ||
@@ -103,0 +135,0 @@ export type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = |
@@ -11,4 +11,4 @@ import type {_DefaultDelimiterCaseOptions} from './delimiter-case.d.ts'; | ||
| @see KebabCase | ||
| @see KebabCasedProperties | ||
| @see {@link KebabCase} | ||
| @see {@link KebabCasedProperties} | ||
@@ -15,0 +15,0 @@ @example |
@@ -11,4 +11,4 @@ import type {_DefaultDelimiterCaseOptions} from './delimiter-case.d.ts'; | ||
| @see KebabCase | ||
| @see KebabCasedPropertiesDeep | ||
| @see {@link KebabCase} | ||
| @see {@link KebabCasedPropertiesDeep} | ||
@@ -15,0 +15,0 @@ @example |
@@ -9,3 +9,3 @@ import type {LiteralToPrimitive} from './literal-to-primitive.d.ts'; | ||
| @see LiteralToPrimitive | ||
| @see {@link LiteralToPrimitive} | ||
@@ -12,0 +12,0 @@ Use-case: Deal with data that is imported from a JSON file. |
+16
-16
@@ -13,3 +13,3 @@ import type {IsFloat} from './is-float.d.ts'; | ||
| @see NegativeInfinity | ||
| @see {@link NegativeInfinity} | ||
@@ -27,3 +27,3 @@ @category Numeric | ||
| @see PositiveInfinity | ||
| @see {@link PositiveInfinity} | ||
@@ -93,4 +93,4 @@ @category Numeric | ||
| @see NegativeInteger | ||
| @see NonNegativeInteger | ||
| @see {@link NegativeInteger} | ||
| @see {@link NonNegativeInteger} | ||
@@ -120,3 +120,3 @@ @category Numeric | ||
| @see Integer | ||
| @see {@link Integer} | ||
@@ -136,4 +136,4 @@ @category Numeric | ||
| @see Negative | ||
| @see Float | ||
| @see {@link Negative} | ||
| @see {@link Float} | ||
@@ -149,4 +149,4 @@ @category Numeric | ||
| @see NegativeInteger | ||
| @see NonNegative | ||
| @see {@link NegativeInteger} | ||
| @see {@link NonNegative} | ||
@@ -165,4 +165,4 @@ @category Numeric | ||
| @see Negative | ||
| @see Integer | ||
| @see {@link Negative} | ||
| @see {@link Integer} | ||
@@ -178,4 +178,4 @@ @category Numeric | ||
| @see NonNegativeInteger | ||
| @see Negative | ||
| @see {@link NonNegativeInteger} | ||
| @see {@link Negative} | ||
@@ -201,4 +201,4 @@ @example | ||
| @see NonNegative | ||
| @see Integer | ||
| @see {@link NonNegative} | ||
| @see {@link Integer} | ||
@@ -219,3 +219,3 @@ @example | ||
| @see Negative | ||
| @see {@link Negative} | ||
@@ -222,0 +222,0 @@ @example |
@@ -88,3 +88,3 @@ /** | ||
| @see PickIndexSignature | ||
| @see {@link PickIndexSignature} | ||
| @category Object | ||
@@ -91,0 +91,0 @@ */ |
+7
-5
@@ -5,5 +5,5 @@ import type {If} from './if.d.ts'; | ||
| /** | ||
| Returns a boolean for whether either of two given types are true. | ||
| Returns a boolean for whether either of two given types is true. | ||
| Use-case: Constructing complex conditional types where multiple conditions must be satisfied. | ||
| Use-case: Constructing complex conditional types where at least one condition must be satisfied. | ||
@@ -14,3 +14,3 @@ @example | ||
| type TT = Or<true, false>; | ||
| type TT = Or<true, true>; | ||
| //=> true | ||
@@ -29,6 +29,7 @@ | ||
| Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases. | ||
| For example, `And<false, boolean>` expands to `And<false, true> | And<false, false>`, which simplifies to `true | false` (i.e., `boolean`). | ||
| For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`). | ||
| @example | ||
| ``` | ||
| import type {And} from 'type-fest'; | ||
| import type {Or} from 'type-fest'; | ||
@@ -80,2 +81,3 @@ type A = Or<false, boolean>; | ||
| @see {@link And} | ||
| @see {@link Xor} | ||
| */ | ||
@@ -82,0 +84,0 @@ export type Or<A extends boolean, B extends boolean> = |
@@ -212,2 +212,11 @@ import type {LiteralUnion} from './literal-union.d.ts'; | ||
| /** | ||
| Specifies requirements for development environment components such as operating systems, runtimes, or package managers. Used to ensure consistent development environments across the team. | ||
| */ | ||
| type DevEngineDependency = { | ||
| name: string; | ||
| version?: string; | ||
| onFail?: 'ignore' | 'warn' | 'error' | 'download'; | ||
| }; | ||
| /** | ||
| A mapping of conditions and the paths to which they resolve. | ||
@@ -568,2 +577,13 @@ */ | ||
| /** | ||
| Define the runtime and package manager for developing the current project. | ||
| */ | ||
| devEngines?: { | ||
| os?: DevEngineDependency | DevEngineDependency[]; | ||
| cpu?: DevEngineDependency | DevEngineDependency[]; | ||
| libc?: DevEngineDependency | DevEngineDependency[]; | ||
| runtime?: DevEngineDependency | DevEngineDependency[]; | ||
| packageManager?: DevEngineDependency | DevEngineDependency[]; | ||
| }; | ||
| /** | ||
| If set to `true`, a warning will be shown if package is installed locally. Useful if the package is primarily a command-line application that should be installed globally. | ||
@@ -570,0 +590,0 @@ |
@@ -7,3 +7,3 @@ import type {If} from './if.d.ts'; | ||
| /** | ||
| @see PartialOnUndefinedDeep | ||
| @see {@link PartialOnUndefinedDeep} | ||
| */ | ||
@@ -10,0 +10,0 @@ export type PartialOnUndefinedDeepOptions = { |
@@ -10,4 +10,4 @@ import type {CamelCaseOptions, _DefaultCamelCaseOptions} from './camel-case.d.ts'; | ||
| @see PascalCase | ||
| @see PascalCasedProperties | ||
| @see {@link PascalCase} | ||
| @see {@link PascalCasedProperties} | ||
@@ -14,0 +14,0 @@ @example |
@@ -10,4 +10,4 @@ import type {CamelCaseOptions, _DefaultCamelCaseOptions} from './camel-case.d.ts'; | ||
| @see PascalCase | ||
| @see PascalCasedPropertiesDeep | ||
| @see {@link PascalCase} | ||
| @see {@link PascalCasedPropertiesDeep} | ||
@@ -14,0 +14,0 @@ @example |
@@ -43,3 +43,3 @@ /** | ||
| @see OmitIndexSignature | ||
| @see {@link OmitIndexSignature} | ||
| @category Object | ||
@@ -46,0 +46,0 @@ */ |
@@ -84,3 +84,3 @@ import type {NonRecursiveType, UnionMin, UnionMax, TupleLength, StaticPartOfArray, VariablePartOfArray, IsArrayReadonly, SetArrayAccess, ApplyDefaultOptions} from './internal/index.d.ts'; | ||
| @see SharedUnionFields | ||
| @see {@link SharedUnionFields} | ||
@@ -87,0 +87,0 @@ @category Object |
@@ -62,4 +62,4 @@ import type {NonRecursiveType} from './internal/index.d.ts'; | ||
| @see SharedUnionFieldsDeep | ||
| @see AllUnionFields | ||
| @see {@link SharedUnionFieldsDeep} | ||
| @see {@link AllUnionFields} | ||
@@ -66,0 +66,0 @@ @category Object |
@@ -107,3 +107,3 @@ import type {ConditionalSimplifyDeep} from './conditional-simplify-deep.d.ts'; | ||
| @see Simplify | ||
| @see {@link Simplify} | ||
| @category Object | ||
@@ -110,0 +110,0 @@ */ |
@@ -55,3 +55,3 @@ /** | ||
| @link https://github.com/microsoft/TypeScript/issues/15300 | ||
| @see SimplifyDeep | ||
| @see {@link SimplifyDeep} | ||
| @category Object | ||
@@ -58,0 +58,0 @@ */ |
@@ -11,4 +11,4 @@ import type {_DefaultDelimiterCaseOptions} from './delimiter-case.d.ts'; | ||
| @see SnakeCase | ||
| @see SnakeCasedProperties | ||
| @see {@link SnakeCase} | ||
| @see {@link SnakeCasedProperties} | ||
@@ -15,0 +15,0 @@ @example |
@@ -11,4 +11,4 @@ import type {_DefaultDelimiterCaseOptions} from './delimiter-case.d.ts'; | ||
| @see SnakeCase | ||
| @see SnakeCasedPropertiesDeep | ||
| @see {@link SnakeCase} | ||
| @see {@link SnakeCasedPropertiesDeep} | ||
@@ -15,0 +15,0 @@ @example |
@@ -59,4 +59,4 @@ import type {IfNotAnyOrNever, IsExactOptionalPropertyTypesEnabled} from './internal/type.d.ts'; | ||
| @see ExtractRestElement | ||
| @see ExcludeRestElement | ||
| @see {@link ExtractRestElement} | ||
| @see {@link ExcludeRestElement} | ||
| @category Array | ||
@@ -63,0 +63,0 @@ */ |
@@ -26,3 +26,3 @@ import type {BuiltIns, HasMultipleCallSignatures} from './internal/index.d.ts'; | ||
| @see Writable | ||
| @see {@link Writable} | ||
| @category Object | ||
@@ -29,0 +29,0 @@ @category Array |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
506909
1.8%197
1.03%12347
1.65%1048
0.19%8
33.33%19
5.56%