You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggestion: Add support for jsdoc-based templates with constrains #24283
Definitely would be helpful. Right now we're using /** @type {...} */ to use bounded generics in js (either defined inline or in an external d.ts file), but that has some serious drawbacks at the moment.
e.g. @type doesn't work on class methods, so we end up assigning the function to the prototype outside of the class body. It's also limited in scope to what's being immediately typed, unlike @template/generics in actual TS, so you can't really apply the type parameters across a whole class, for instance.
Readability is also not a small concern (all crammed into that @type comment :), and being able to declare as regular @params, etc jsdoc tags would be fantastic.
Compatibility with future Closure support isn't super important to us, at least, as we use enough TS-specific features (typeof, indexed access) that we have to do a cleaning pass on the code before passing to Closure anyways. If the solution is reasonable (like the above suggestion), there's also no reason Closure can't adopt it anyways.
Activity
mhegazy commentedon May 21, 2018
I think this should be:
brendankenny commentedon May 21, 2018
Definitely would be helpful. Right now we're using
/** @type {...} */to use bounded generics in js (either defined inline or in an externald.tsfile), but that has some serious drawbacks at the moment.e.g.
@typedoesn't work on class methods, so we end up assigning the function to the prototype outside of theclassbody. It's also limited in scope to what's being immediately typed, unlike@template/generics in actual TS, so you can't really apply the type parameters across a whole class, for instance.Readability is also not a small concern (all crammed into that
@typecomment :), and being able to declare as regular@params, etc jsdoc tags would be fantastic.Compatibility with future Closure support isn't super important to us, at least, as we use enough TS-specific features (
typeof, indexed access) that we have to do a cleaning pass on the code before passing to Closure anyways. If the solution is reasonable (like the above suggestion), there's also no reason Closure can't adopt it anyways.sandersn commentedon Jun 4, 2018
#24600 has this change.