Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< 返回工具列表
T

ts-essentials

> 编程语言
开源

All essential TypeScript types in one place

4.1K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

All essential TypeScript types in one place

ts-essentials

All essential TypeScript types in one place

## Install ```sh 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](https://github.com/ts-essentials/ts-essentials/tree/master#TypeScript-dependency-table) As we really want types to be stricter, we require enabled [strictNullChecks](https://www.typescriptlang.org/tsconfig#strictNullChecks) in your project ## API `ts-essentials` is a set of high-quality, useful TypeScript types that make writing type-safe code easier. ### Basic - [`Builtin`](/lib/built-in) - Matches primitive, function, date, error or regular expression - [`JsonArray`](/lib/json-array) - Matches any [JSON array](https://www.rfc-editor.org/rfc/rfc8259#section-3) - [`JsonObject`](/lib/json-object) - Matches any [JSON object](https://www.rfc-editor.org/rfc/rfc8259#section-3) - [`JsonPrimitive`](/lib/json-primitive) - Matches any [JSON primitive value](https://www.rfc-editor.org/rfc/rfc8259#section-3) - [`JsonValue`](/lib/json-value) - Matches any [JSON value](https://www.rfc-editor.org/rfc/rfc8259#section-3) - [`KeyofBase`](/lib/key-of-base) - [`keyofStringsOnly`](https://www.typescriptlang.org/tsconfig#keyofStringsOnly)-tolerant analogue for `PropertyKey` - [`Prettify`](/lib/prettify/) - flattens type and makes it more readable on the hover in your IDE - [`Primitive`](/lib/primitive) - Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) - [`StrictExclude`](/lib/strict-exclude) - Constructs a type by excluding from `UnionType` all union members that are assignable to `ExcludedMembers`. This is stricter version of [`Exclude`](https://www.typescriptlang.org/docs/handbook/utility-types.html#excludeuniontype-excludedmembers) - [`StrictExtract`](/lib/strict-extract) - Constructs a type by extracting from `Type` all union members that are assignable to `Union`. This is stricter version of [`Extract`](https://www.typescriptlang.org/docs/handbook/utility-types.html#extracttype-union) - [`StrictOmit`](/lib/strict-omit) - Constructs a type by picking all properties from `Type` and then removing `Keys`. This is stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys) - [`Writable`](/lib/writable) - Constructs a type with removed `readonly` for all properties of `Type`, meaning the properties of the constructed type can be reassigned ### Utility types - [`AsyncOrSync`](/lib/async-or-sync) - Constructs a type with `Type` or `PromiseLike` - [`AsyncOrSyncType`](/lib/async-or-sync-type) - Unwraps `AsyncOrSync` type - [`Dictionary`](/lib/dictionary) - Constructs a required object type which property keys are `Keys` (`string` by default) and which property values are `Type` - [`Merge`](/lib/merge) - 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`](/lib/merge-n) - Constructs a type by merging objects with type `Merge` in tuple `Tuple` recursively - [`Newable`](/lib/newable) - Constructs a class type with constructor which has return type `ReturnType` - [`OmitNeverProperties`](/lib/omit-never-properties) - Constructs a type by picking all properties from type `Type`, which values don't equal to `never` - [`OmitProperties`](/lib/omit-properties) - Constructs a type by picking all properties from type `Type` and removing those properties which values equal to `Value` - [`Opaque`](/lib/opaque) - Constructs a type which is a subset of `Type` with a specified unique token `Token` - [`PathValue`](/lib/path-value) - Constructs a path value for type `Type` and path `Path` - [`Paths`](/lib/paths) - Constructs a union type by picking all possible paths for type `Type` - [`PickProperties`](/lib/pick-properties) - Constructs a type by picking all properties from type `Type` which values equal to `Value` - [`PublicInterface`](/lib/public-interface) - Constructs a type by extracting only the public members of `Type`, producing a plain object-compatible interface - [`RequireAtLeastOne`](/lib/require-at-least-one) - 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`](/lib/require-at-most-one) - 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`](/lib/safe-dictionary) - Constructs an optional object type which property keys are `Keys` (`string` by default) and which property values are `Type` - [`UnionToIntersection`](/lib/union-to-intersection) - Constructs a intersection type from union type `Union` - [`ValueOf`](/lib/value-of) - 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`](/lib/xor) - 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`](/lib/mark-optional) - Constructs a type by picking all properties from type `Type` where properties `Keys` are set as optional, meaning they aren't required - [`MarkReadonly`](/lib/mark-readonly) - Constructs a type by picking all properties from type `Type` where properties `Keys` are set to `readonly`, meaning they cannot be reassigned - [`MarkRequired`](/lib/mark-required) - Constructs a type by picking all properties from type `Type` where properties `Keys` are set as required - [`MarkWritable`](/lib/mark-writable) - 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`](/lib/buildable) - 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`](/lib/deep-mark-optional) - 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`](/lib/mark-optional). - [`DeepMarkRequired`](/lib/deep-mark-required) - 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`](/lib/mark-required). - [`DeepNonNullable`](/lib/deep-non-nullable) - 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`](https://www.typescriptlang.org/docs/handbook/utility-types.html#nonnullabletype) - [`DeepNullable`](/lib/deep-nullable) - Constructs a type by picking all properties from type `Type` recursively and include `null` property values for all of them - [`DeepOmit`](/lib/deep-omit) - 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`](./lib/strict-deep-omit/). - [`DeepPartial`](/lib/deep-partial) - 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`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype) - [`DeepPick`](/lib/deep-pick) - 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`](./lib/strict-deep-pick/). - [`DeepReadonly`](/lib/deep-readonly) - 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`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype) - [`DeepRequired`](/lib/deep-required) - Constructs a type by picking all properties from type `Type` recursively and setting as required. To make properties required on one level, use [`Required`](https://www.typescriptlang.org/docs/handbook/utility-types.html#requiredtype) - [`DeepUndefinable`](/lib/deep-undefinable) - Constructs a type by picking all properties from type `Type` recursively and include `undefined` property values for all of them - [`DeepWritable`](/lib/deep-writable) - 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` - [`StrictDeepOmit`](/lib/strict-deep-omit) - 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`](/lib/strict-deep-pick) - 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`](/lib/optional-keys) - Constructs a union type by picking all optional properties of object type `Type` - [`PickKeys`](/lib/pick-keys) - Constructs a union type by picking all properties of object type `Type` which values are assignable to type `Value` - [`ReadonlyKeys`](/lib/readonly-keys) - Constructs a union type by picking all `readonly` properties of object type `Type`, meaning their values cannot be reassigned - [`RequiredKeys`](/lib/required-keys) - Constructs a union type by picking all required properties of object type `Type` - [`UnionKeys`](/lib/union-keys) - Constructs a union type by picking all properties from all union members of `UnionType` - [`WritableKeys`](/lib/writable-keys) - Constructs a union type by picking all writable properties of object type `Type`, meaning their values can be reassigned ### Type checkers - [`IsAny`](/lib/is-any) - Returns `true` when type `Type` is `any`. Otherwise returns `false` - [`IsExact`](/lib/is-exact) - Returns `Type` when type `Type` and `Shape` are identical. Otherwise returns `never` - [`IsNever

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •Builtin - Matches primitive, function, date, error or regular expression
  • •JsonArray - Matches any JSON array
  • •JsonObject - Matches any JSON object
  • •JsonPrimitive - Matches any
  • •JsonValue - Matches any JSON value
  • •KeyofBase -
  • •Prettify<Type> - flattens type and makes it more readable on the hover in your IDE
  • •Primitive - Matches any
  • •StrictExclude<UnionType, ExcludedMembers> - Constructs a type by excluding from UnionType
  • •StrictExtract<Type, Union> - Constructs a type by extracting from Type all union members

> 标签

TypeScriptessentialstoolboxtype-level-programmingtypes

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言