Wayou

泛型类型

TypeScript 中,类型(interface, type)是可以声明成泛型的,这很常见。

interface Props<T> {
  content: T;
}

这表明 Props 接口定义了这么一种类型:

  • 它是包含一个 content 字段的对象
  • content 字段的类型由使用时的泛型 T 决定
type StringProps = Props<string>;

let props: StringProps;

props = {
  // 

分类:

技术点:

相关文章: