vue源码学习 --- flow(3)

原文: https://flow.org/en/docs/types/functions/

一. function

函数声明使用:
(1) 函数的参数
(2) 函数的返回值

1. (1) 函数的参数, 即在参数后加符号 :(冒号), 冒号后跟上类型

function concat(a: string, b: string): string {
  return a + b;
}
concat("foo", "bar"); // Works!
// concat(true, false);  // Error!

2. 函数的返回值, 一定要返回规定的返回值类型

function method(): number {
    return 1;           // Works!
  // return '1';                // Error!
}
method();

vue源码学习 --- flow(4)
https://www.jianshu.com/p/e5f519640d49

你可能感兴趣的:(vue源码学习 --- flow(3))