About this project
TypeFest is a collection of reusable TypeScript types intended to fill gaps in the built-in type system. It can be installed from npm as type-fest, and individual types are imported with TypeScript's type-only import syntax. The documented development version requires TypeScript 5.9 or newer, an ESM project, and strict mode enabled in tsconfig. The maintainer also notes that needed types may be copy-pasted without credit.
The library covers a broad set of type-level use cases. Basic types include Primitive, Class, Constructor, AbstractClass, TypedArray, ObservableLike, and character sets such as LowercaseLetter, UppercaseLetter, DigitCharacter, and Alphanumeric.
Object and utility types form the largest section. Examples include Except for omitting keys, Writable and WritableDeep for removing readonly modifiers, Merge and MergeDeep for combining types, PartialDeep and RequiredDeep for recursive optionality and requirement, ReadonlyDeep for deep immutability, and SetOptional, SetRequired, SetReadonly, and SetNonNullable for adjusting selected properties. It also provides conditional selection types such as ConditionalKeys, ConditionalPick, and ConditionalExcept, nested helpers such as PickDeep, OmitDeep, Get, and Paths, and union helpers such as LiteralUnion, TaggedUnion, UnionToIntersection, KeysOfUnion, and DistributedOmit.
Type guard and boolean types include If, IsAny, IsNever, IsUnknown, IsNull, IsUndefined, IsTuple, IsUnion, IsLiteral, IsStringLiteral, IsNullable, and equality checks such as IsEqual. JSON support includes JsonValue, JsonPrimitive, JsonObject, JsonArray, Jsonifiable, and Jsonify. Other groups cover structured cloning, async types such as Promisable, AsyncReturnType, and Asyncify, string manipulation types such as Split, Replace, Trim, RemovePrefix, and RemoveSuffix, and array or tuple types such as ArrayElement, LastArrayElement, Includes, Join, ArraySlice, FixedLengthArray, and NonEmptyTuple.
The README links each type name to its source definition for detailed documentation. A related package, ts-extras, provides runtime functions for some of the same concepts. The project accepts proposals and pull requests for additional commonly needed types, subject to its contributing guidelines.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.