Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Interestingly, Google Closure Compiler has <a href="https://developers.google.com/closure/compiler/docs/js-for-compiler#generics" rel="nofollow">support for generic types</a>, with a syntax like this:</p> <pre><code>/** * @constructor * @template T */ Foo = function() { ... }; /** @return {T} */ Foo.prototype.get = function() { ... }; /** @param {T} t */ Foo.prototype.set = function(t) { ... }; /** @type {!Foo.&lt;string&gt;} */ var foo = new Foo(); var foo = /** @type {!Foo.&lt;string&gt;} */ (new Foo()); </code></pre> <p>As JSDuck <a href="https://github.com/senchalabs/jsduck/wiki/Type-Definitions" rel="nofollow">already supports</a> Closure Compiler style type annotations, it should be already possible to write types like <code>{MyClass.&lt;T&gt;}</code>. JSDuck doesn't however uses a <a href="https://github.com/senchalabs/jsduck/wiki/%40template" rel="nofollow">@template tag</a> for a different purpose altogether, but one implement its own custom tag like <code>@typevar</code> or override the builtin <code>@template</code> to do your bidding using the <a href="https://github.com/senchalabs/jsduck/wiki/Custom-tags" rel="nofollow">custom tags system</a>.</p> <p>But as there is no actual generic types support in JSDuck, it won't check your generic types. On the contrary, it will probably complain, that you're referencing an unknown type <code>T</code> and others. But it's easy to make JSDuck ignore certain types (or type variables) by using <code>--external=T</code>.</p> <p>One final note. The Closure Compiler doesn't support your <code>extends</code> syntax in type variables, and I don't really see why would you write <code>T extends Bird</code> and then <code>{MyArray&lt;T&gt;}</code>, instead of just writing <code>{MyArray&lt;Bird&gt;}</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload