我无法确定Closure是否支持JSDoc数组语法,例如string[]
。
我没有看到它记录在https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#user-content-the-javascript-type-language上。但是,JSDoc支持它,而且已经存在了一段时间,所以令我惊讶的是Closure也不支持它。
((JSdoc表示按https://jsdoc.app/tags-type.html闭包不支持此功能,并在catharsis
类型解析器中提及了这一点:https://github.com/hegemonic/catharsis,但我不知道这是否可以过时。)
如果支持,我还想知道是否可以在其后立即添加可选的=
(在括号中不包含前一个表达式)。
(作为奖励,我想知道记录类型是否可以像[{key?: number}
一样,在闭包中具有可选键。)
JSDocs和Closure Compiler有所不同。有关详细信息,请使用Closure documentation。
闭包中的字符串数组的类型为Array<string>
。