npm
npm i -D typyx
pnpm
pnpm i -D typyx
Requires TypeScript v5.0+.
Check out the full API reference for detailed usage examples and docs.
Assign<Obj, ObjArr> - Copies all enumerable own properties from one target object to a source array of objects.FilterBy<Obj, P> - Filters keys from the object type Obj based on a specified predicate P.Flip<Obj> - Flips the keys and values of an object type Obj.ImmutableKeys<Obj> - Retrieves the readonly keys from an object type Obj.Keys<T> - Retrieves the union of keys of a type T.KeysOfUnion<T> - Extracts the union of keys from a union of object types.KeysToValues<Obj> - Creates a reverse mapping from values to keys for a simple object type.MakeOptional<T, K> - Makes the specified keys K optional while preserving the original modifiers of all other keys.MakeRequired<T, K> - Makes the specified keys K required while preserving the original modifiers of all other keys.Methods<Obj> - Gets the literal names of keys that are methods in an object type Obj.MutableKeys<Obj> - Retrieves the mutable keys from an object type Obj.NonRequiredKeys<Obj> - Returns all non-required keys of an object type Obj.NotIncluded - Marker type used with deep pruning utilities to completely omit fields.OmitByType<Obj, T> - Omits properties from Obj whose types are assignable to T.OmitCommonKeys<Obj1, Obj2> - Omits any keys shared by Obj1 and Obj2.OmitExactlyByTypeDeep<Obj, T> - Deeply omits properties whose types exactly match T.PickByType<Obj, T> - Picks properties from Obj whose types are assignable to T.PickCommonKeys<Obj1, Obj2> - Gets the common keys between two object types.PickExactlyByType<Obj, T> - Picks properties from Obj whose types exactly match T.Properties<Obj> - Gets the literal names of keys that are non-method properties in an object type Obj.Prune<T, N = NotIncluded> - Recursively omits properties of type N from T.ReplaceKeys<Obj1, P, Obj2> - Replaces properties P in Obj1 with the corresponding properties from Obj2.RequiredKeys<Obj> - Gets the required keys of an object type Obj.Vals<Obj> - Gets the union of value types from an object type.DeepAwaited<T> - Recursively resolves all nested Promise types to their underlying values.DeepImmutable<Obj> - Recursively makes every property in Obj readonly.DeepMutable<Obj> - Recursively removes readonly from every property in Obj.DeepNotRequired<Obj> - Recursively makes all properties optional.DeepOmit<Obj, P> - Recursively omits specified nested properties from an object based on path P.DeepPick<Obj, P> - Deeply picks properties from a nested object based on path P.DeepRequired<Obj> - Recursively makes all properties required.DeepToPrimitive<Obj> - Recursively transforms an object type into one whose properties are their primitive counterparts.IsDeepImmutable<Obj> - Checks if all nested properties of Obj are immutable.IsDeepMutable<Obj> - Checks if all nested properties of Obj are mutable.IsDeepNotRequired<Obj> - Checks if all nested properties of Obj are optional.IsDeepRequired<Obj> - Checks if all nested properties of Obj are required.Paths<Obj> - Generates all possible dot-separated key paths from a nested object type.ExclusiveUnion<T> - Creates a union type where each variant keeps its own required properties while excluding incompatible ones.KeysOfUnion<T> - Extracts the full key union across a union of object types.NotAssignableTo<U, V> - Excludes all members of U that are assignable to V.TupleToUnion<T> - Converts a tuple type into a union type.UnionToIntersection<U> - Converts a union type into an intersection type.UnionToTuple<T> - Converts a union type into a tuple type.Append<Arr, Item> - Adds an item to the end of a tuple.EitherOneOrMany<T> - Represents either a single value of type T or an array of T.Head<Arr> - Gets the first element of a tuple.IsArrayIncludesTypeof<Arr, T> - Checks whether an array type Arr is assignable to T[].Last<Arr> - Gets the last element of a tuple.NonEmptyArray<T> - Represents an array containing at least one element of type T.Pop<Arr> - Removes the last element of a tuple.Prepend<Arr, Item> - Adds an item to the start of a tuple.SizedTuple<T, N> - Creates a tuple of length N where each element is of type T.Tail<Arr> - Removes the first element of a tuple.Tuple<T> - Narrows T to a tuple type and rejects regular arrays.UniqueArray<T> - Creates a unique array type from an array type T.Zip<L, L1> - Pairs elements from two tuples by index into a tuple of pairs.CapitalizeFirst<T> - Capitalizes the first character of a string literal type.EnforcedString<Prefix, Contains, Suffix> - Restricts a string using optional prefix, substring, and suffix constraints.EqualStrlen<S1, S2> - Checks whether two strings have the same length.FilledString<S> - Errors on an empty string literal ''.NumerifyString<S> - Converts a string literal into a Numeric when possible.StringEndsWith<S, E> - Checks whether a string S ends with E.StringStartsWith<S, St> - Checks whether a string S starts with St.StringifyPrimitive<P> - Turns a primitive value type into its string representation.StrBetween<S, Min, Max> - Ensures a string S has a length within [Min, Max].Strlen<S> - Computes the length of a string S.StrMax<S, Max> - Ensures that a string S has length less than or equal to Max.StrMin<S, Min> - Ensures that a string S has length greater than or equal to Min.Abs<N> - Gets the absolute value of a Numeric.Even<T> - Represents an even Numeric.Float<N> - Type representing a float.Integer<N> - Represents an integer.IsFloat<N> - Checks if a given numeric type is a float.IsInteger<N> - Checks if a given numeric type is an integer.IsNegative<N> - Checks if a numeric type is negative.IsNegativeFloat<N> - Checks if a numeric type is a negative float.IsNegativeInteger<N> - Checks if a numeric type is a negative integer.IsPositive<N> - Checks if a numeric type is positive.IsPositiveFloat<N> - Checks if a numeric type is a positive float.IsPositiveInteger<N> - Checks if a numeric type is a positive integer.NegativeFloat<N> - Represents a negative Float<N>.NegativeFloatString<S> - Represents a negative float parsed from a string.NegativeInteger<N> - Represents a negative Integer<N>.NegativeIntegerString<S> - Represents a negative integer parsed from a string.Numeric - Represents number | bigint.Odd<T> - Represents an odd Numeric.PositiveFloat<N> - Represents a positive Float<N>.PositiveFloatString<S> - Represents a positive float parsed from a string.PositiveInteger<N> - Represents a positive Integer<N>.PositiveIntegerString<S> - Represents a positive integer parsed from a string.PositiveRange<N, M> - Represents a range of positive integers from N to M inclusive.And<B1, B2> - Logical AND between two boolean types.Equals<X, Y> - Checks if two types are exactly equal.If<C, Do, Else> - Resolves to Do if C is true, otherwise Else.IfEquals<T, P, Do, Else> - Resolves to Do if T equals P, otherwise Else.IfExtends<T, P, Do, Else> - Resolves to Do if T extends P, otherwise Else.Nand<B1, B2> - Logical NAND between two boolean types.Nor<A, B> - Logical NOR between two boolean types.Not<B> - Negates a boolean type.Or<B1, B2> - Logical OR between two boolean types.Xand<A, B> - Logical XAND between two boolean types.Xnor<A, B> - Logical XNOR between two boolean types.Xor<B1, B2> - Logical XOR between two boolean types.Extends<T, U> - Evaluates whether type T is assignable to type U.FalsyProperties<T> - Extracts falsy properties from an object type T.Is<T, U> - Checks if two types are exactly identical.IsAnyFunction<T> - Checks if T is an arbitrary function type.IsArray<T> - Checks if T is an array type.IsBigInt<T> - Checks if T is a bigint.IsBoolean<T> - Checks if T is a boolean.IsExactlyAny<T> - Checks if T is exactly any.IsExactlyBigInt<T> - Checks if T is exactly bigint.IsExactlyNumber<T> - Checks if T is exactly number.IsExactlyString<T> - Checks if T is exactly string.IsExactlySymbol<T> - Checks if T is exactly symbol.IsExactlyUnknown<T> - Checks if T is exactly unknown.IsFalsy<T> - Checks if a given type T is Falsy.IsFunction<T> - Checks if a given type T is a function.IsNever<T> - Checks if a type resolves to never.IsNewable<T> - Checks if a type T is Newable.IsNot<T, U> - Checks if two types are not identical.IsNullable<T> - Checks if a type T is Nullable.IsNumber<T> - Checks if a type T is a number.IsNumeric<T> - Checks if a type T is Numeric.IsObject<T> - Checks if a type T qualifies as an object.IsString<T> - Checks if a type T is a string.IsSymbol<T> - Checks if a type T is a symbol.IsTruthy<T> - Checks if a type T resolves to a truthy value.IsUnknown<T> - Checks if a type T is assignable to unknown.TestType<T1, T2, Expected> - Tests whether T1 and T2 match the expected relationship.TruthyProperties<T> - Extracts truthy properties from an object type T.AnyFunction - Represents any function accepting any arguments and returning any value.EmptyObject - Represents a non-nullish object-like value.ExcludeNull<T> - Excludes null from a type T.ExcludeNullable<T> - Excludes Nullable from a type T.ExcludeUndefined<T> - Excludes undefined from a type T.Falsy - Represents JavaScript falsy values.Maybe<T> - Represents a type that may be Nullable.MaybeUndefined<T> - Represents a type that may be undefined.MaybeUnknown<T> - Represents a type widened with unknown.Message<T> - Used to surface readable error messages instead of never.Newable - Represents constructor functions that can be invoked with new.NewType<New, Base> - Creates a branded type derived from an existing base type.Nullable - Represents a type that can be null or undefined.Optional<T> - Represents a type that may be null, similar to Python's Optional or Rust's Option.PartialExcept<T, P> - Makes all properties in T optional except those in P, which remain required.Primitive - Represents all JavaScript primitive types.Simplify<T> - Flattens and normalizes a type for better readability.UnknownFunction - Represents a function accepting unknown arguments and returning unknown.The best way to understand how these types work is to check the tests directory.
See releases.
MIT © @rccyx