AnyArray_2 |
类型工具库。 |
AnyAsyncFunction |
任意异步函数。 |
AnyFunction_2 |
任意函数。 |
AnyObject_2 |
任意对象。 |
Asyncify |
<p>Create an async version of the given function type, by boxing the return type in Promise while keeping the same parameter types.</p><p>Use-case: You have two functions, one synchronous and one asynchronous that do the same thing. Instead of having to duplicate the type definition, you can use Asyncify to reuse the synchronous type.</p> |
AsyncOrSync |
Useful as a return type in interfaces or abstract classes with missing implementation |
AsyncReturnType |
<p>Unwrap the return type of a function that returns a Promise .</p><p>There has been [discussion](https://github.com/microsoft/TypeScript/pull/35998) about implementing this type in TypeScript.</p> |
Buildable |
Combination of DeepPartial and DeepWritable |
CamelCase |
<p>Convert a string literal to camel-case.</p><p>This can be useful when, for example, converting some kebab-cased command-line flags or a snake-cased database result.</p> |
Class |
<p>Matches a [class ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).</p><p> Basic</p> |
ConstantCase |
<p>Convert a string literal to screaming-snake-case.</p><p>This can be useful when, for example, converting a camel-cased object property to a screaming-snake-cased SQL column name.</p> |
Defined |
去除类型 T 中的 undefined。 |
DelimiterCase |
<p>Convert a string literal to a custom string delimiter casing.</p><p>This can be useful when, for example, converting a camel-cased object property to an oddly cased one.</p> |
DotPath |
|
DotPathValue |
|
ElementOf |
Easily extract the type of a given array’s elements |
Finite |
<p>A finite number . You can’t pass a bigint as they are already guaranteed to be finite.</p><p>Use-case: Validating and documenting parameters.</p> |
FirstParameter |
返回函数 T 第一个参数的类型。 |
FixedLengthArray |
<p>Create a type that represents an array of the given type and length. The array’s length and the Array prototype methods that manipulate its length are excluded in the resulting type.</p><p>Please participate in [this issue](https://github.com/microsoft/TypeScript/issues/26223) if you want to have a similiar type built into TypeScript.</p><p>Use-cases: - Declaring fixed-length tuples or arrays with a large number of items. - Creating a range union (for example, 0 | 1 | 2 | 3 | 4 from the keys of such a type) without having to resort to recursive types. - Creating an array of coordinates with a static length, for example, length of 3 for a 3D vector.</p> |
Head |
Functional programming essentials |
Integer |
<p>A number that is an integer. You can’t pass a bigint as they are already guaranteed to be integers.</p><p>Use-case: Validating and documenting parameters.</p> |
IsAny |
判断 T 是否是 any 类型。 |
IsEmptyArray |
判断 T 是否是空数组。 |
IsEmptyObject |
判断 T 是否是空对象。 |
IsNever |
判断 T 是否是 never 类型。 |
JsonArray |
<p>Matches a JSON array.</p><p> Basic</p> |
JsonObject |
<p>Matches a JSON object.</p><p>This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don’t use this as a direct return type as the user would have to double-cast it: jsonObject as unknown as CustomResponse . Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: interface CustomResponse extends JsonObject { … } .</p><p> Basic</p> |
JsonValue |
Matches any valid JSON value. |
KebabCase |
<p>Convert a string literal to kebab-case.</p><p>This can be useful when, for example, converting a camel-cased object property to a kebab-cased CSS class name or a command-line flag.</p> |
LiteralUnion |
<p>Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.</p><p>Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.</p><p>This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it’s not needed anymore.</p> |
Merge |
Merge 2 types, properties types from the latter override the ones defined on the former type |
Negative |
<p>A negative number /bigint (-∞ < x < 0 )</p><p>Use-case: Validating and documenting parameters.</p> |
NegativeInfinity |
<p>Matches the hidden -Infinity type.</p><p>Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.</p> |
NegativeInteger |
<p>A negative (-∞ < x < 0 ) number that is an integer. Equivalent to Negative<Integer<T>> .</p><p>You can’t pass a bigint as they are already guaranteed to be integers, instead use Negative<T> .</p><p>Use-case: Validating and documenting parameters.</p> |
NonEmptyArray |
非空数组类型。 |
NonNegative |
<p>A non-negative number /bigint (0 <= x < ∞ ).</p><p>Use-case: Validating and documenting parameters.</p> |
NonNegativeInteger |
<p>A non-negative (0 <= x < ∞ ) number that is an integer. Equivalent to NonNegative<Integer<T>> .</p><p>You can’t pass a bigint as they are already guaranteed to be integers, instead use NonNegative<T> .</p><p>Use-case: Validating and documenting parameters.</p> |
NonNullableDeep |
Like NonNullable but recursive |
Nullable |
|
NullableDeep |
Recursive nullable |
OmitBy |
Omit all properties of given type in object type |
OmitDeep |
Recursively omit deep properties |
OmitStrict |
Similar to the builtin Omit, but checks the filter strictly. |
OneOrMore |
同 T | T[] 。 |
OptionalKeys |
Gets keys of an object which are optional |
PackageJson |
<p>Type for [npm’s package.json file](https://docs.npmjs.com/creating-a-package-json-file). Also includes types for fields used by other popular projects, like TypeScript and Yarn.</p><p> Miscellaneous</p> |
PartialBy |
Mark some properties as optional, leaving others unchanged |
PartialDeep |
Like Partial but recursive |
PascalCase |
Converts a string literal to pascal-case. |
Path |
获取对象的路径。最多支持 7 级路径。 |
PathValue |
获取对象的路径值。最多支持 7 级路径。 |
PickBy |
Pick all properties of given type in object type |
PositiveInfinity |
<p>Matches the hidden Infinity type.</p><p>Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.</p> |
ReadonlyDeep |
Like Readonly but recursive |
ReadonlyKeys |
Gets keys of an object which are readonly |
RequireAllOrNone |
<p>Create a type that requires all of the given keys or none of the given keys. The remaining keys are kept as is.</p><p>Use-cases: - Creating interfaces for components with mutually-inclusive keys.</p><p>The caveat with RequireAllOrNone is that TypeScript doesn’t always know at compile time every key that will exist at runtime. Therefore RequireAllOrNone can’t do anything to prevent extra keys it doesn’t know about.</p> |
RequireAtLeastOne |
Create a type that requires at least one of the given keys. The remaining keys are kept as is. |
RequiredBy |
Mark some properties as required, leaving others unchanged |
RequiredDeep |
Like Required but recursive |
RequiredKeys |
Gets keys of an object which are required |
RequireExactlyOne |
<p>Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.</p><p>Use-cases: - Creating interfaces for components that only need one of the keys to display properly. - Declaring generic keys in a single place for a single use-case that gets narrowed down via RequireExactlyOne .</p><p>The caveat with RequireExactlyOne is that TypeScript doesn’t always know at compile time every key that will exist at runtime. Therefore RequireExactlyOne can’t do anything to prevent extra keys it doesn’t know about.</p> |
Simplify |
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability. |
SnakeCase |
<p>Convert a string literal to snake-case.</p><p>This can be useful when, for example, converting a camel-cased object property to a snake-cased SQL column name.</p> |
Tail |
|
UnionToIntersection |
<p>Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).</p><p>Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).</p> |
ValueOf |
Easily extract the type of a given object’s values |
Writable |
Make readonly object writable |
WritableDeep |
Like Writable but recursive |
WritableKeys |
Gets keys of an object which are writable |