简体   繁体   English

此打字稿方案是什么意思?

[英]What does this typescript scheme mean?

What does this typescript scheme mean? 此打字稿方案是什么意思?

  interface Validator<T extends FormControl> {
     (c:T): {[error: string]:any};
  }

I'm a bit new to Typescript and I'm trying to understand this interface function. 我对Typescript有点陌生,并且试图了解此接口功能。 In particular, what does the <T extends FormControl> represent? 特别是<T extends FormControl>代表什么?

And what {[error: string]:any} signify? {[error: string]:any}表示什么? My guess is the return object of the function is an object with a key of type 'string' and a value of 'any' type. 我的猜测是该函数的返回对象是一个键类型为'string'且值为'any'类型的对象。 Can someone help clarify? 有人可以帮忙澄清一下吗?

what does the T extends FormControl represent T extends FormControl代表什么

This is generics . 这是泛型 Basically the <T extends FormControl> introduces a new type T that should be the subtype of FormControl type. 基本上, <T extends FormControl>引入了一个新的类型T ,它应该是FormControl类型的子类型。

The Validator is a function that takes an object of any type that is a subtype of FormControl , including FormControl type. Validator是一种函数,它接受任何类型的对象,该对象是FormControl的子类型,包括FormControl类型。

what {[error: string]:any} signify? {[error: string]:any}表示什么?

It specifies a new indexable type with properties of string type. 它使用字符串类型的属性指定新的可索引类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM