facebook / facebook/flow

Flow fails to check Disjoint Unions as object value type

未关闭
#1,959 11 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Typing: unions/intersections
主要语言
Rust
星标
22.3k
派生
1.9k
PR 合并指标
30 天内没有已合并 PR

描述

``` javascript
type ASTLiteralNode = {
type: 'Literal',
value: any
};

type ASTThisNode = {
type: 'ThisExpression'
};

class AST {
static Literal = 'Literal';
static ThisExpression = 'ThisExpression';

static constants: { [key: string]: (ASTThisNode | ASTLiteralNode) } = {
'this': { type: AST.ThisExpression },
'null': { type: AST.Literal, value: null },
'true': { type: AST.Literal, value: true },
'false': { type: AST.Literal, value: false }
};
}
```

I got the errors:

```
src/parse.js:242
242: 'null': { type: AST.Literal, value: null },
^^^^^^^^^^^ string. Expected string literal `ThisExpression`, got `Literal` instead
228: type: 'ThisExpression'
^^^^^^^^^^^^^^^^ string literal `ThisExpression`

src/parse.js:243
243: 'true': { type: AST.Literal, value: true },
^^^^^^^^^^^ string. Expected string literal `ThisExpression`, got `Literal` instead
228: type: 'ThisExpression'
^^^^^^^^^^^^^^^^ string literal `ThisExpression`

src/parse.js:244
244: 'false': { type: AST.Literal, value: false }
^^^^^^^^^^^ string. Expected string literal `ThisExpression`, got `Literal` instead
228: type: 'ThisExpression'
^^^^^^^^^^^^^^^^ string literal `ThisExpression`
```

Also, I have enabled `esproposal.class_instance_fields` and `esproposal.class_static_fields` in `.flowconfig`.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。