【问题标题】:TypeScript reuse type genericsTypeScript 重用类型泛型
【发布时间】:2022-12-03 14:55:38
【问题描述】:

How to extend generic type generics of type to function? Is it possible to reuse generics without copy paste?

type T<FormType extends \'edit\' | \'create\' = \'create\', RecordType extends Record = Record> = {
   type: FormType,
   record: RecordType
}

const func = <FormType extends \'edit\' | \'create\' = \'create\', RecordType extends Record = Record>(props: T<FormType, RecordType>) => ...

How to extend this &lt;FormType extends \'edit\' | \'create\' = \'create\', RecordType extends Record = Record&gt; from type generics to function generics without copy paste?

  • You can\'t. The closest you can do is create a type alias for \'edit\' | \'create\'.

标签: typescript generics typescript-typings typescript-generics


【解决方案1】:
猜你喜欢
  • 2019-05-30
  • 2021-04-23
  • 2021-12-06
  • 2019-09-17
  • 2020-01-05
  • 2021-01-03
  • 1970-01-01
  • 2021-05-21
  • 1970-01-01
相关资源
最近更新 更多