google / google/closure-compiler

Validate returned value usage for functions not annotated with @return

Open
#466 3 comments 0 reactions 0 assignees View on GitHub
enhancement P3 Types
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Here's the case:

```
function foo()
{
// do something
// do not return any value
}

function bar()
{
console.log(1 + foo());
}
```

In this case, the `foo()` function has no `@return` annotation, since it does not return anything. However, it used to `@return {number}`, and `bar()` contains code relying on this. Now that `foo()` has been modified to not return anything, the compiler considers its return type as `?` (unchecked), and hence does not detect the error in `bar()`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.