让我们直截了当。我是Flow的新手.我想为不同的变量声明单一数据类型,就像我们在 Java
中所做的那样。
public class Person {
String name, nickName;
}
当前代码
// @flow
export default class Person {
name : string;
nickName : string;
}
我想要的是这样的
// @flow
export default class Person {
name, nickName : string;
}
不同变量的一种数据类型。这可能使用 Flow
吗? .我搜索了网络,阅读了官方文档,但找不到任何积极的东西。
最佳答案
不,这不可能。该语法基于即将到来的 class fields proposal它不支持这种语法。以下是相关的生产规则:
ClassElement: MethodDefinitionstatic
MethodDefinition FieldDefinition;
;
FieldDefinition: ClassElementName Initializeropt ClassElementName: PropertyName PropertyName: LiteralPropertyName ComputedPropertyName LiteralPropertyName: IdentifierName StringLiteral NumericLiteral ComputedPropertyName:[
AssignmentExpression]
关于javascript - 不同变量的单一数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50578307/