8d969a23cb
* Support @template as a class type parameter Still need to do the following: 1. Correctly get jsdoc host in predicate. 2. Make this work for constructor functions too. 3. Scan rest of codebase for other usages of the type parameters property that should be calls to getEffectiveTypeParameterDeclarations. 4. Rename tp to something more readable, like typar or ts'. * Use jsdoc host declaration to find container * Longer names for type parameters * Fix renaming operation * Update fourslash test * Support @template for JS constructors * Look for both outer and tag type parameters * Improve naming to improve code clarity
26 lines
410 B
TypeScript
26 lines
410 B
TypeScript
// @allowJs: true
|
|
// @checkJs: true
|
|
// @noEmit: true
|
|
// @Filename: templateTagOnConstructorFunctions.js
|
|
|
|
/**
|
|
* @template {T}
|
|
* @typedef {(t: T) => T} Id
|
|
* @param {T} t
|
|
*/
|
|
function Zet(t) {
|
|
/** @type {T} */
|
|
this.u
|
|
this.t = t
|
|
}
|
|
/**
|
|
* @param {T} v
|
|
* @param {Id} id
|
|
*/
|
|
Zet.prototype.add = function(v, id) {
|
|
this.u = v || this.t
|
|
return id(this.u)
|
|
}
|
|
var z = new Zet(1)
|
|
z.t = 2
|
|
z.u = false
|