Fancy Front End Fancy Front End
  • 开始上手
  • 基础
  • 调度器(Scheduler)
  • 更新器(Updater)
  • 渲染器(Render)
  • 更新周期
  • hooks 原理
  • 总结
  • 📙 React源码漂流记
  • 开始上手
  • 基础
  • reactivity
  • runtime-core
  • runtime-dom
  • Awesome Web
  • Awesome NodeJS
话题
  • 导航
  • Q&A
  • 幻灯片
  • 关于
  • 分类
  • 标签
  • 归档
博客 (opens new window)
GitHub (opens new window)

Jonsam NG

让有意义的事变得有意思,让有意思的事变得有意义
  • 开始上手
  • 基础
  • 调度器(Scheduler)
  • 更新器(Updater)
  • 渲染器(Render)
  • 更新周期
  • hooks 原理
  • 总结
  • 📙 React源码漂流记
  • 开始上手
  • 基础
  • reactivity
  • runtime-core
  • runtime-dom
  • Awesome Web
  • Awesome NodeJS
话题
  • 导航
  • Q&A
  • 幻灯片
  • 关于
  • 分类
  • 标签
  • 归档
博客 (opens new window)
GitHub (opens new window)
  • 开始上手
  • Plan 计划
  • typescript-utility

    • 开始阅读
    • 基础

      • 本章概要
      • basic-types 基础类型
      • type-manipulation 类型操作
      • classes 类类型
      • reference 其他
        • Utility Types 实用类型
      • type-zoo
    • 类型工具

  • single-spa源码

  • qiankun源码

  • webpack

  • axios

  • solid

  • vite源码

  • jquery源码

  • snabbdom

  • am-editor

  • html2canvas

  • express

  • acorn源码

  • immutable.js源码

  • web
  • typescript-utility
  • 基础
jonsam
2022-04-14
目录

reference 其他

# Utility Types 实用类型

  • Partial<Type>

Constructs a type with all properties of Type set to optional. This utility will return a type that represents all subsets of a given type. 构造具有 Type 的所有属性设置为可选的类型。此实用程序将返回表示给定类型的所有子集的类型。

  • Required<Type>

Constructs a type consisting of all properties of Type set to required. The opposite of Partial. 构造一个包含 Type 设置为 required 的所有属性的类型。与 Partial 相反。

  • Readonly<Type>

Constructs a type with all properties of Type set to readonly, meaning the properties of the constructed type cannot be reassigned. 构造具有 Type 的所有属性设置为只读的类型,这意味着不能重新分配构造类型的属性。

  • Record<Keys, Type>

Constructs an object type whose property keys are Keys and whose property values are Type. This utility can be used to map the properties of a type to another type. 构造属性键为 Keys、属性值为 Type 的对象类型。此实用工具可用于将一个类型的属性映射到另一个类型。

  • Pick<Type, Keys>

Constructs a type by picking the set of properties Keys (string literal or union of string literals) from Type. 通过从 Type 中选择一组属性 Keys (字符串文本或字符串文本的并集) 来构造类型。

  • Omit<Type, Keys>

Constructs a type by picking all properties from Type and then removing Keys (string literal or union of string literals). 通过从 Type 中选取所有属性,然后移除 Keys (字符串文字或字符串文字的并集) 来构造类型。

  • Exclude<Type, ExcludedUnion>

Constructs a type by excluding from Type all union members that are assignable to ExcludedUnion. 通过从类型中排除可分配给 ExcludedUnion 的所有联合成员来构造类型。

  • Extract<Type, Union>

Constructs a type by extracting from Type all union members that are assignable to Union. 通过从 Type 中提取可分配给 Union 的所有联合成员来构造类型。

  • NonNullable<Type>

Constructs a type by excluding null and undefined from Type. 通过从 Type 中排除 null 和 undefined 来构造类型。

  • Parameters<Type>

Constructs a tuple type from the types used in the parameters of a function type Type. 从函数类型类型的参数中使用的类型构造元组类型。

  • ConstructorParameters<Type>

Constructs a tuple or array type from the types of a constructor function type. It produces a tuple type with all the parameter types (or the type never if Type is not a function). 从构造函数类型的类型构造元组或数组类型。它生成具有所有参数类型的元组类型 (如果 Type 不是函数,则生成 never 类型)。

  • ReturnType<Type>

Constructs a type consisting of the return type of function Type. 构造一个类型,包含函数 Type 的返回类型。

  • InstanceType<Type>

Constructs a type consisting of the instance type of a constructor function in Type. 构造由 Type 中构造函数的实例类型组成的类型。

  • ThisParameterType<Type>

Extracts the type of the this parameter for a function type, or unknown if the function type has no this parameter. 提取函数类型的此参数的类型,如果函数类型没有此参数,则未知。

  • OmitThisParameter<Type>

Removes the this parameter from Type. If Type has no explicitly declared this parameter, the result is simply Type. Otherwise, a new function type with no this parameter is created from Type. Generics are erased and only the last overload signature is propagated into the new function type. 从 Type 中移除此参数。如果 Type 没有显式声明此参数,则结果只是 Type。否则,将从 Type 创建没有此参数的新函数类型。泛型被擦除,只有最后一个重载签名被传播到新的函数类型中。

function toHex(this: Number) {
  return this.toString(16);
}
 
const fiveToHex: OmitThisParameter<typeof toHex> = toHex.bind(5);
 
console.log(fiveToHex());
1
2
3
4
5
6
7
  • ThisType<Type>

This utility does not return a transformed type. Instead, it serves as a marker for a contextual this type. Note that the noImplicitThis flag must be enabled to use this utility. 此实用程序不返回转换后的类型。相反,它可以作为这种类型上下文的标记。请注意,必须启用 noImplicitThis 标志才能使用此实用程序。

  • Intrinsic String Manipulation Types
  1. Uppercase<StringType>
  2. Lowercase<StringType>
  3. Capitalize<StringType>
  4. Uncapitalize<StringType>
编辑 (opens new window)
上次更新: 2022/09/06, 14:25:16
classes 类类型
type-zoo

← classes 类类型 type-zoo→

最近更新
01
渲染原理之组件结构与 JSX 编译
09-07
02
计划跟踪
09-06
03
开始上手
09-06
更多文章>
Theme by Vdoing | Copyright © 2022-2022 Fancy Front End | Made by Jonsam by ❤
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式