MCPcopy
hub / github.com/ts-essentials/ts-essentials

github.com/ts-essentials/ts-essentials @v10.2.1 sqlite

repository ↗ · DeepWiki ↗ · release v10.2.1 ↗
249 symbols 352 edges 182 files 1 documented · 0%
README

ts-essentials

ts-essentials

All essential TypeScript types in one place 🤙

<a href="https://www.npmjs.com/package/ts-essentials" title="View this project on NPM">
  <img alt="Version" src="https://img.shields.io/npm/v/ts-essentials.svg">
</a>
<img alt="Downloads" src="https://img.shields.io/npm/dm/ts-essentials.svg">
<a href="https://github.com/ts-essentials/ts-essentials/actions?query=branch%3Amaster" title="View Github Build status">
  <img alt="Build status" src="https://github.com/ts-essentials/ts-essentials/actions/workflows/ci.yml/badge.svg">
</a>
<a href="https://t.me/ts_essentials" title="Get support in Telegram">
  <img alt="Telegram" src="https://img.shields.io/badge/-telegram-red?color=white&logo=telegram">
</a>
<a href="https://github.com/ts-essentials/ts-essentials/raw/v10.2.1/package.json"><img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a>

Install

npm install --save-dev ts-essentials

👉 We require typescript>=4.5. If you're looking for support for older TS versions, please have a look at the TypeScript dependency table

👉 As we really want types to be stricter, we require enabled strictNullChecks in your project

API

ts-essentials is a set of high-quality, useful TypeScript types that make writing type-safe code easier.

Basic

Utility types

  • AsyncOrSync<Type> - Constructs a type with Type or PromiseLike<Type>
  • AsyncOrSyncType<Type> - Unwraps AsyncOrSync type
  • Dictionary<Type, Keys?> - Constructs a required object type which property keys are Keys (string by default) and which property values are Type
  • Merge<Object1, Object2> - Constructs a type by picking all properties from Object1 and Object2. Property values from Object2 override property values from Object1 when property keys are the same
  • MergeN<Tuple> - Constructs a type by merging objects with type Merge in tuple Tuple recursively
  • Newable<ReturnType> - Constructs a class type with constructor which has return type ReturnType
  • OmitNeverProperties<Type> - Constructs a type by picking all properties from type Type, which values don't equal to never
  • OmitProperties<Type, Value> - Constructs a type by picking all properties from type Type and removing those properties which values equal to Value
  • Opaque<Type, Token> - Constructs a type which is a subset of Type with a specified unique token Token
  • PathValue<Type, Path> - Constructs a path value for type Type and path Path
  • Paths<Type> - Constructs a union type by picking all possible paths for type Type
  • PickProperties<Type, Value> - Constructs a type by picking all properties from type Type which values equal to Value
  • PublicInterface<Type> - Constructs a type by extracting only the public members of Type, producing a plain object-compatible interface
  • RequireAtLeastOne<Type, Keys?> - Constructs a type with at least one required key from Keys (keyof Type by default) and other keys from Type which are not part of Keys
  • RequireAtMostOne<Type, Keys?> - Constructs a type with at most one required key from Keys (keyof Type by default) and other keys from Type which are not part of Keys
  • SafeDictionary<Type, Keys?> - Constructs an optional object type which property keys are Keys (string by default) and which property values are Type
  • UnionToIntersection<Union> - Constructs a intersection type from union type Union
  • ValueOf<Type> - Constructs a type for type Type and equals to a primitive for primitives, array elements for arrays, function return type for functions or object property values for objects
  • XOR<Type1, Type2, Type3?, ..., Type50?> - Construct a type which is assignable to either type Type1, Type2 but not both. Starting in ts-essentials@10, it supports up to 50 generic types.

Mark wrapper types

  • MarkOptional<Type, Keys> - Constructs a type by picking all properties from type Type where properties Keys are set as optional, meaning they aren't required
  • MarkReadonly<Type, Keys> - Constructs a type by picking all properties from type Type where properties Keys are set to readonly, meaning they cannot be reassigned
  • MarkRequired<Type, Keys> - Constructs a type by picking all properties from type Type where properties Keys are set as required
  • MarkWritable<Type, Keys> - Constructs a type by picking all properties from type Type where properties Keys remove readonly modifier, meaning they can be reassigned

Deep wrapper types

  • Buildable<Type> - Constructs a type by combining DeepPartial and DeepWritable, meaning all properties from type Type are recursively set as non-readonly and optional, meaning they can be reassigned and aren't required
  • DeepMarkOptional<Type, KeyPathUnion> - Constructs a type by picking all properties from type Type where properties by paths KeyPathUnion are set as optional. To mark properties optional on one level, use MarkOptional<Type, Keys>.
  • DeepMarkRequired<Type, KeyPathUnion> - Constructs a type by picking all properties from type Type where properties by paths KeyPathUnion are set as required. To mark properties required on one level, use MarkRequired<Type, Keys>.
  • DeepNonNullable<Type> - Constructs a type by picking all properties from type Type recursively and exclude null and undefined property values from all of them. To make properties non-nullable on one level, use NonNullable<Type>
  • DeepNullable<Type> - Constructs a type by picking all properties from type Type recursively and include null property values for all of them
  • DeepOmit<Type, Filter> - Constructs a type by picking all properties from type Type and removing properties which values are never or true in type Filter. If you'd like type Filter to be validated against a structure of Type, please use StrictDeepOmit<Type, Filter>.
  • DeepPartial<Type> - Constructs a type by picking all properties from type Type recursively and setting them as optional, meaning they aren't required. To make properties optional on one level, use Partial<Type>
  • DeepPick<Type, Filter> - Constructs a type by picking set of properties, which have property values never or true in type Filter, from type Type. If you'd like type Filter to be validated against a structure of Type, please use StrictDeepPick<Type, Filter>.
  • DeepReadonly<Type, OverrideDeepReadonlyOptions?> - Constructs a type by picking all properties from type Type recursively and setting readonly modifier, meaning they cannot be reassigned. To make properties readonly on one level, use Readonly<Type>
  • DeepRequired<Type> - Constructs a type by picking all properties from type Type recursively and setting as required. To make properties required on one level, use Required<Type>
  • DeepUndefinable<Type> - Constructs a type by picking all properties from type Type recursively and include undefined property values for all of them
  • DeepWritable<Type> - Constructs a type by picking all properties from type Type recursively and removing readonly modifier, meaning they can be reassigned. To make properties writable on one level, use Writable<Type>
  • StrictDeepOmit<Type, Filter> - Constructs a type by picking all properties from type Type and removing properties which values are never or true in type Filter. The type Filter is validated against a structure of Type.
  • StrictDeepPick<Type, Filter> - Constructs a type by picking set of properties, which have property values never or true in type Filter, from type Type. The type Filter is validated against a structure of Type.

Key types

  • OptionalKeys<Type> - Constructs a union type by picking all optional properties of object type Type
  • PickKeys<Type, Value> - Constructs a union type by picking all properties of object type Type which values are assignable to type Value
  • ReadonlyKeys<Type> - Constructs a union type by picking all readonly properties of object type Type, meaning their values cannot be reassigned
  • RequiredKeys<Type> - Constructs a union type by picking all required properties of object type Type
  • UnionKeys<UnionType> - Constructs a union type by picking all properties from all union members of UnionType
  • WritableKeys<Type> - Constructs a union type by picking all writable properties of object type Type, meaning their values can be reassigned

Type checkers

  • IsAny<Type> - Returns true when type Type is any. Otherwise returns false
  • IsExact<Type, Shape> - Returns Type when type Type and Shape are identical. Otherwise returns never
  • IsNever<Type> - Returns true when type Type is never. Otherwise returns false
  • IsUnknown<Type> - Returns true when type Type is unknown. Otherwise returns false
  • IsTuple<Type> - Returns Type when type Type is tuple. Otherwise returns never
  • NonEmptyObject<Object> - Returns Object when Object has at least one key. Otherwise returns never
  • NonUnion<Type> - Returns Type when Type is not an union. Otherwise returns never

Arrays and Tuples

Change case

Extension points exported contracts — how you extend this code

ExtendedFunction (Interface)
(no doc)
lib/deep-readonly/index.test.ts
Circle (Interface)
(no doc)
lib/omit-never-properties/index.test.ts
Shape (Interface)
(no doc)
lib/public-interface/index.test.ts
ExtendedFunction (Interface)
(no doc)
lib/deep-writable/index.test.ts
Newable (Interface)
(no doc)
lib/newable/index.ts
ExtendedFunction (Interface)
(no doc)
lib/deep-partial/index.test.ts
ExtendedFunction (Interface)
(no doc)
lib/deep-required/index.test.ts
Company (Interface)
(no doc)
lib/path-value/index.test.ts

Core symbols most depended-on inside this repo

isExact
called by 22
lib/functions/is-exact/index.ts
noop
called by 2
lib/functions/noop/index.ts
findTsVersion
called by 2
scripts/find-ts-version.js
createFactoryWithConstraint
called by 1
lib/functions/create-factory-with-constraint/index.ts
assert
called by 1
lib/functions/assert/index.ts
applyRules
called by 1
scripts/update-test-tsconfig.js
updateTsConfig
called by 1
scripts/update-test-tsconfig.js
writeTsVersion
called by 1
scripts/sync-ts-version.js

Shape

Function 178
Interface 36
Class 20
Method 13
Enum 2

Languages

TypeScript100%

Modules by API surface

lib/public-interface/index.test.ts18 symbols
lib/json-value/index.test.ts13 symbols
lib/deep-readonly/index.test.ts13 symbols
lib/xor/function-parameters.test.ts11 symbols
lib/deep-writable/index.test.ts11 symbols
lib/is-exact/index.test.ts9 symbols
lib/paths/index.test.ts8 symbols
lib/deep-required/index.test.ts8 symbols
lib/strict-extract/index.test.ts7 symbols
lib/path-value/index.test.ts6 symbols
lib/deep-partial/index.test.ts6 symbols
lib/prettify/index.test.ts5 symbols

Dependencies from manifests, versioned

@changesets/cli2.20.0 · 1×
@typescript-eslint/parser8.15.0 · 1×
conditional-type-checks1.0.4 · 1×
eslint9.15.0 · 1×
eslint-plugin-expect-type0.4.3 · 1×
prettier2.0.0 · 1×
rimraf3.0.2 · 1×
semver7.6.3 · 1×
tsx4.10.5 · 1×
typescript4.5.0 · 1×

For agents

$ claude mcp add ts-essentials \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact