google / google/closure-compiler

Support for type annotating arrays using `string[]` syntax rather than `Array<string>`

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

Description

```js
/** @type {string[]} */
// ^
// JSC_TYPE_PARSE_ERROR: Bad type annotation. expected closing }
const x = ["hi"];
```

This is supported in both TypeScript and JSDoc. It would be nice if closure supported this as well.

[Appspot demo](https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F%252F%2520ADD%2520YOUR%2520CODE%2520HERE%250A%252F**%2520%2540type%2520%257Bstring%255B%255D%257D%2520*%252F%250Aconst%2520x%2520%253D%2520%255B%2522hi%2522%255D%253B%250Aconsole.log(x)%253B%250A)

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.