Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: John Harris Newsgroups: comp.lang.javascript Subject: Re: TypeScript JSDoc generic member function Date: Thu, 26 Oct 2023 11:28:00 +0100 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: Reply-To: jgharris@ic4life.net MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 26 Oct 2023 10:28:01 -0000 (UTC) Injection-Info: dont-email.me; posting-host="6ac4105fc3faa08080f6993d4601fc4a"; logging-data="1610847"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XOdQxBqkE276lqh9wjSf2QHnfc/z/aiI=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:lDzxzyZ/NEE66AbqjZw9KFeiUIE= In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.javascript:41478 On 25/10/2023 19:03, Julio Di Egidio wrote: > I cannot seem to find a way to tell TypeScript with JSDoc that a > member function of some object/interface takes a type parameter. > > Here is a minimal example illustrating the problem: > > ```js > /** >  * @template {unknown} T >  * @callback IGet >  * @param {string} key >  * @returns {T | undefined} >  */ > > /** >  * @typedef IGetter >  * @type {object} >      * _@template {unknown} T  // how to write this? >  * @property {IGet} get >  */ > ``` > > Error: Cannot find name 'T'. > > That of course can be done in TypeScript, but how to do it with > JSDoc?  Is it at all possible? > > Link to TypeScript playground: > > > Julio That's the trouble with documentation programs. Users have no control over the program's prejudices. John