what does the colon mean in Javascript after function?

后端 未结 2 733
不知归路
不知归路 2021-01-19 15:57

I saw the Facebook F8 app code there is a \":\" after the function

function setup(): React.Component {
  ...
}

what does this mean?

<
2条回答
  •  庸人自扰
    2021-01-19 16:38

    I think that is the return type of the function setup(), if you analyze different examples you will see that syntax in method parameters too

    function user(state: State = initialState, action: Action): State {
      // some code
      return state;
    }
    

    edit: is flow, a static type checker from facebook: https://flow.org/

提交回复
热议问题