Var*_*pta 4 javascript node.js jest react-native
有在文件中的一个的一段代码react-native回购这里如下所示:
export type Operation =
& {instanceID: DebugID}
& (
| {type: 'mount', payload: string}
| {type: 'insert child', payload: {toIndex: number, content: string}}
| {type: 'move child', payload: {fromIndex: number, toIndex: number}}
| {type: 'replace children', payload: string}
| {type: 'replace text', payload: string}
| {type: 'replace with', payload: string}
| {type: 'update styles', payload: mixed /* Style Object */}
| {type: 'update attribute', payload: {[name: string]: string}}
| {type: 'remove attribute', payload: string});
Run Code Online (Sandbox Code Playgroud)
单身&和|运营商应该做什么?
当我在react-native应用程序上运行测试用例时,我Unexpected token在第一个|操作员的此文件中收到错误jest.我正在运行节点版本5.9.1.我的另一个正在运行节点版本的队友8.x不会遇到意外的令牌错误.所以,我假设这些运算符是在节点后版本中引入的5.9.1.那是对的吗?
sbk*_*ing 10
在这种情况下,这些是针对Flow类型的.它们代表联盟类型和交叉类型.Flow注释为您的代码提供静态类型检查,在这里它们定义了一个对象必须Operation被Flow 视为有效类型的结构,例如将对象传递给期望Operation此形式的参数的函数时.它们不是JS语言的官方部分.要使用它们,您需要在babel中启用流注释或使用flow-remove-types:
https://flow.org/en/docs/install/
但是,&和|运算符确实存在于JavaScript中,但是用于按位运算.
| 归档时间: |
|
| 查看次数: |
484 次 |
| 最近记录: |