What function () means: any {"means

I saw this snippet here :

render: function(): any {
  var thread = this.state.thread;
  var name = thread ? thread.name : "";
  var messageListItems = this.state.messages.map(getMessageListItem);
  return (
    <div className="message-section">
    <h3 className="message-thread-heading">{name}</h3>
// ...

What does the part function(): any{in the first line mean ?

Sorry if this was asked before, but itโ€™s really hard to find it, especially when you donโ€™t know what he called.

+4
source share
1 answer

This is not part of JavaScript, it is an optional feature added by Flow , a JavaScript preprocessor.

Essentially, the stream adds a type checking function, and to use it you add a hint type to the characters. In this case, it : anyis a type hint for the method render, that is, the method can return any type.

docs any:

any - , . any . any " , , ", . , Flow , .


: ES4 , . , ES- ActionScript 3.

+6

All Articles