官术网_书友最值得收藏!

  • Expert Angular
  • Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
  • 69字
  • 2021-07-15 17:05:34

Generic interfaces

We can also define generic interfaces using the T type variable, as follows:

interface GenericFunc<T> { 
    (arg: T): T; 
} 
function func<T>(arg: T): T { 
    return arg; 
} 
var myFunc: GenericFunc<number> = func; 

Here, we defined a generic interface and the myFunc variable of the GenericFunc type, passing the number data type for the T type variable. Then, this variable is assigned with a function named func.

主站蜘蛛池模板: 安多县| 镇巴县| 江山市| 乳山市| 雷波县| 驻马店市| 兴山县| 遂平县| 庆云县| 张家口市| 鄂托克旗| 闽清县| 峨边| 福鼎市| 财经| 渝中区| 安徽省| 镶黄旗| 噶尔县| 紫金县| 玛沁县| 绥滨县| 灵山县| 家居| 阳新县| 宜春市| 枝江市| 夹江县| 乌兰浩特市| 佛学| 林口县| 湖口县| 吉首市| 波密县| 长子县| 阿荣旗| 土默特右旗| 石狮市| 荣成市| 康保县| 阳西县|