简体   繁体   English

此ES6函数声明如何有效?

[英]How is this ES6 function declaration valid?

How is this function declaration valid in ES6? 此函数声明在ES6中如何有效? What does it mean? 这是什么意思? I've found it in the source code of a React Native project. 我已经在React Native项目的源代码中找到了它。

'use strict';

import React, { Component } from 'React';
// some more imports...

function setup():React.Component {

    class Root extends Component {

        // constructor and render functions...   

    }
    return Root
}

export default setup;

I have removed a few lines that are not important to see my issue. 我删除了一些对我的问题不重要的行。

I could not find anything related to ES6 or Javascript regarding function declaration followed by a colon. 在函数声明后跟冒号的情况下,我找不到与ES6或Javascript有关的任何内容。

That code is typed with flow , Facebook's static type checker (akin to TypeScript). 该代码使用Facebook的静态类型检查器flow (类似于TypeScript)输入。 It's not valid ES6, it's a superset of the ES6 syntax. 这不是有效的ES6,而是ES6语法的超集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM