facebook / facebook/flow

The `throw` operator should be more strict

Aberta
#2,172 3 comentários 0 reações 0 responsáveis Ver no GitHub
linter
Linguagem predominante
Rust
Estrelas
22.3k
Forks
1.9k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

I tried searching, but I didn't find any existing issues about this.

Currently, using version 0.30.0 of flow-bin, the following code shows no errors:

```
function foo() {
throw null;
}

function bar() {
throw 5;
}

function qux() {
throw [];
}
```

It seems that the `throw` operator will accept any type.

I think it should only accept `Error`. If that is too restrictive, it could be relaxed to `Error | string`.

This actually bit me when I was writing a function which accepts an optional argument: if the argument is not provided, then it will `throw` `undefined`, which is not what I wanted.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.