34e68efdae
* Parse (and mostly support) template tag constraints A bunch of tests hit the asserts I added though. * Messy version is finished. Need to add a few tests * Refactor to be smaller * Small refactor + Add one test * Another test * Minor cleanup * Fix error reporting on type parameters on ctors * Simplify syntax of `@template` tag This is a breaking change, but in my sample, nobody except webpack used the erroneous syntax. I need to improve the error message, so jsdocTemplateTag3 currently fails to remind me of that. * Better error message for template tag * Fix fourslash baselines * Another fourslash update * Address PR comments * Simplify getEffectiveTypeParameterDeclarations Make checkGrammarConstructorTypeParameters do a little more work
30 lines
508 B
TypeScript
30 lines
508 B
TypeScript
// @allowJs: true
|
|
// @checkJs: true
|
|
// @noEmit: true
|
|
// @Filename: templateTagOnClasses.js
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {(t: T) => T} Id
|
|
*/
|
|
/** @template T */
|
|
class Foo {
|
|
/** @typedef {(t: T) => T} Id2 */
|
|
/** @param {T} x */
|
|
constructor (x) {
|
|
this.a = x
|
|
}
|
|
/**
|
|
*
|
|
* @param {T} x
|
|
* @param {Id<T>} 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
|