"type" 是什么意思,问号在 ECMA 6 中有特殊用途吗?

What does "type" mean and is there is a special use for a question mark in ECMA 6?

在 React Native Example Code 中,你会发现 at some files type 语句,它封装了 4 个属性(我想猜),其中最后两个以问题为后缀标记.

type MapRegion = {
  latitude: number,
  longitude: number,
  latitudeDelta?: number,
               ^============   What are these...
  longitudeDelta?: number,
};              ^===========...question marks for? 

这一切意味着什么?在 ECMAScript 6 规范中,我找不到任何关于 "type".

的内容

flow,一种将静态类型添加到JavaScript的转译器语言。

type MapRegion = {
  latitude: number,
  longitude: number,
  // This property is nullable
  latitudeDelta?: number,
  // This property is nullable
  longitudeDelta?: number,
}; 

// The following does not cause a compilation error

/* @flow */
var a:MapRegion = {
  latitude: 1,
  longitude: 3 
};

Facebook 实际上正在使用他们的静态类型转译 JavaScript 版本,称为 'Flow'。这就是你在这里看到的。它与 TypeScript 有点相似,因此它们很容易被误认为是彼此。

http://flowtype.org/