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

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.

主站蜘蛛池模板: 深水埗区| 交口县| 禄劝| 喀喇沁旗| 陆良县| 湘阴县| 旬阳县| 都兰县| 宁远县| 板桥市| 行唐县| 邵武市| 大姚县| 咸阳市| 伊宁县| 辽宁省| 巴林右旗| 天镇县| 永年县| 阿坝| 台中市| 富源县| 河南省| 仲巴县| 景洪市| 南岸区| 临安市| 巴马| 海口市| 安庆市| 鄂尔多斯市| 北票市| 贵南县| 永泰县| 吉木乃县| 玛多县| 兰考县| 城市| 天镇县| 大埔县| 土默特左旗|