typescript(四)typescript 函数参数及返回值类型说明
发布时间
阅读量:
阅读量
此前我们已对TS中静态类型定义涉及的函数类型定义进行过阐述,现进行简要回顾:
const fnA: () => string = () => { return '1' }
const fnB: () => number = () => 6
const fnC: () => boolean = () => true
进一步说明:在接口设计过程中,函数类型的声明方式是怎样的呢?关于接口的后续内容将在之后进行讲解。
interface Ifn {
(one: number, two: number): number
}
let fniA : Ifn
fniA = function (one, two) {
return one + two
}
fniA(2, 4)
console.log(fniA(2, 4)) // 6
以下将分别介绍在TypeScript中如何对函数参数及函数返回值进行类型声明的方法。
1.ts中函数
全部评论 (0)
还没有任何评论哟~
