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
29 lines
488 B
TypeScript
29 lines
488 B
TypeScript
// @allowJs: true
|
|
// @checkJs: true
|
|
// @noEmit: true
|
|
// @Filename: templateTagOnClasses.js
|
|
|
|
/**
|
|
* @template {T}
|
|
* @typedef {(t: T) => T} Id
|
|
*/
|
|
class Foo {
|
|
/** @typedef {(t: T) => T} Id2 */
|
|
/** @param {T} x */
|
|
constructor (x) {
|
|
this.a = x
|
|
}
|
|
/**
|
|
*
|
|
* @param {T} x
|
|
* @param {Id} y
|
|
* @param {Id2} alpha
|
|
* @return {T}
|
|
*/
|
|
foo(x, y, alpha) {
|
|
return alpha(y(x))
|
|
}
|
|
}
|
|
var f = new Foo(1)
|
|
var g = new Foo(false)
|
|
f.a = g.a
|