google / google/closure-compiler

Inline return annotation for anonymous functions

Open
#1,063 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Current long form:

``` javascript
/**
* @return {number}
*/
var myFoo = function foo(x) { return x - 1; }
```

Current inline form:

``` javascript
var myFoo = function /** number */ foo(x) { return x - 1; }
```

**Desired** inline form for anonymous functions:

``` javascript
var myFoo = function /** number */ (x) { return x - 1; }
```

... or equivalent that would fail:

``` javascript
var myFoo = function /** number */ (x) { return "a"; }
```

Would need another example adding here:
https://github.com/google/closure-compiler/wiki/Annotating-Types

As discussed here:
https://github.com/google/closure-compiler/issues/1061#issuecomment-128080193

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.