【发布时间】:2020-08-06 02:04:38
【问题描述】:
我在 react-table 中使用 typescript 时试图理解代码,但遇到了这些类型的接口
export interface TableInstance<D extends object = {}>
extends Omit<TableOptions<D>, 'columns' | 'pageCount'>,
UseTableInstanceProps<D> {}
注意界面中的两个extends关键字。调用时生成一个表实例
export function useTable<D extends object = {}>(
options: TableOptions<D>,
...plugins: Array<PluginHook<D>>
): TableInstance<D>;
之后我可以访问从UseTableInstanceProps继承的TableInstance属性
我是不是说TableInstance 是一个继承Omit 和UseTableInstanceProps 属性的对象?
这个省略是什么意思?有什么资源可以帮助我理解这种语法吗?
/**
* Construct a type with the properties of T except for those in type K.
*/
type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
【问题讨论】:
-
我的回答有帮助吗?
标签: typescript typescript-typings typescript-generics