google / google/closure-compiler

JSDoc string literals not supported in Closure

Open
#3,390 2 comments 0 reactions 0 assignees View on GitHub
enhancement internal-issue-created triage-done
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

String literals are supported in many JSDoc interpreters, but not in Closure.
For example:
```
/**
* @description Compress a file
* @param {string} filename
* @param {"zip"|"gz"} type
*/
function compressFile(filename, type) {
console.log(`Compressing file ${filename} with ${type}`);
}
compressFile("myfile.txt", "gz");
```

but when I run it against the Closure Compiler, I get the following output:
```
poc.js:4: WARNING - Bad type annotation. Unknown type "zip"
* @param {"zip"|"gz"} type
^

poc.js:4: WARNING - Bad type annotation. Unknown type "gz"
* @param {"zip"|"gz"} type
^
```
There's some discussion of this feature here: https://github.com/jsdoc/jsdoc/issues/629
What's the correct way to achieve this with Closure? I can't find anything about it in the documentation.

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.