facebook / facebook/flow

Flow fails to check Disjoint Unions as object value type

Abierto
#1,959 11 comentarios 0 reacciones 0 asignados Ver en GitHub
Typing: unions/intersections
Lenguaje dominante
Rust
Estrellas
22.3k
Forks
1.9k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

``` 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`.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.