Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #41478
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: TypeScript JSDoc generic member function |
| Date | 2023-10-26 11:28 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <uhdevh$1h52v$1@dont-email.me> (permalink) |
| References | <uhbl9k$u0u5$1@dont-email.me> |
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<T>} 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:
> <https://www.typescriptlang.org/play?strictNullChecks=true&noUncheckedIndexedAccess=true&allowUnusedLabels=true&noUnusedLocals=true&noUnusedParameters=true&removeComments=true&target=1&module=1&pretty=true&isolatedModules=true&useUnknownInCatchVariables=true&exactOptionalPropertyTypes=true&noFallthroughCasesInSwitch=true&noImplicitOverride=true&noPropertyAccessFromIndexSignature=true&keyofStringsOnly=true&filetype=js#code/PQKhCgAIUgBAXApgWwA4BsCGTIG8CuAdgNaED2A7oQL6QAqUMsAxpuugEabPGQCSAcUTxGcVJgBOmZHgDO8CQEtCAc1rFEAT1GwJw-BMKy8dSAB9IRACaIAZssRXqjYOHCgI0OPE2pHd-iF4JAkdHz88Mg4AK0RmeGdIJKSYAH0EFAxsRDwiUkoaeiTgYEgAC0pIeDJICiUceDLFWQB+HVQJMj8JHzxBYQAeOgA+WhVhF3AgA>
>
> Julio
That's the trouble with documentation programs. Users have no control
over the program's prejudices.
John
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
TypeScript JSDoc generic member function Julio Di Egidio <julio@diegidio.name> - 2023-10-25 20:03 +0200 Re: TypeScript JSDoc generic member function John Harris <niam@jghnorth.org.uk.invalid> - 2023-10-26 11:28 +0100 Re: TypeScript JSDoc generic member function Julio Di Egidio <julio@diegidio.name> - 2023-10-26 16:25 +0200
csiph-web