2016-09-29 44 views
1

我試圖用Google的Closure編譯器編譯ExtJS 6.2.0。還有像ExtJS的源代碼以下注釋:Google Closure編譯器不識別類型註釋

* @param {Ext.data.TreeModel[]} records An array of records.

關閉的錯誤了,因爲它不承認這個類型的註釋。錯誤如下所示:

extjs-6.2.0/build/ext-all-debug.js:248792: ERROR - Bad type annotation. expecting a variable name in a @param tag. See https://github.com/google/closure-compiler/wiki/Bad-Type-Annotation for more information. 
    * @param {Ext.data.TreeModel[]} data.records An Array of Models representing the 

我不一定會在提供的URL中看到解決方案。在ExtJS中也有很多這樣的類型,我猜編譯器會遇到問題。

這裏有一個簡單的解決方法嗎?我可以從彙編中刪除--jscomp_error checkTypes,但我寧願按照正確的方式來執行此操作。

回答

2

您顯示的註釋與Google閉包編譯器不兼容。相反,它會被寫入

* @param {Array<Ext.data.TreeModel>} records An array of records. 

我懷疑他們正在使用JSDoc因爲註釋Ext.data.TreeModel[]與JSDoc兼容,見http://usejsdoc.org/tags-type.html

Closure Compiler從JSDoc語法開始,但在過去的5年左右時間裏,這兩者有點分歧。這裏描述閉包編譯器註釋:https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler(滾動到底部的「輸入表達式」)。

可能會更改一些註釋以使其與閉包編譯器兼容。但是有一些關於編譯器的ADVANCED模式使用的代碼如何工作的假設,這些代碼可能不遵循這些模式。見a recent thread about a similar question

+0

您要鏈接的線程似乎不是有效的鏈接。 – randombits

+0

我修改了鏈接,現在應該可以工作。 – owler

相關問題