- Annotate types and functions/methods with JSDoc
- Closure Compiler syntax is also accepted
- Use plugin for Babel: https://github.com/azu/babel-plugin-jsdoc-to-assert
Показаны сообщения с ярлыком JSDoc. Показать все сообщения
Показаны сообщения с ярлыком JSDoc. Показать все сообщения
16 янв. 2017 г.
Run-time assertions for JSDoc @param and @type tags in Babel
12 мая 2014 г.
Generics in JSDoc
/** * @interface * @template T */ MyEnumerable = function () { }; /** * @param {T} item */ MyEnumerable.prototype.add = function (item) { }; /** * @constructor * @template TItemType * @extends {MyEnumerable.<TItemType>} */ MyList = function () { }; /** * @param {TItemType} item the item */ MyList.prototype.addItem = function (item) { }; /** @type {MyEnumerable.<string>}*/ var enumerable = new MyList(); enumerable.add("Bob"); // correct enumerable.add(123); // correct warning: number is not assignable to type string /** @type {MyList.<string>}*/ var list = new MyList(); list.add("Bob"); // incorrect warning: number is not assignable to type TITemType list.addItem("Bob"); // correct
Now works in WebStorm
Подписаться на:
Сообщения (Atom)