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
434 B
TypeScript
30 lines
434 B
TypeScript
// @allowJs: true
|
|
// @checkJs: true
|
|
// @noEmit: true
|
|
// @Filename: templateTagOnConstructorFunctions.js
|
|
|
|
/**
|
|
* @template U
|
|
* @typedef {(u: U) => U} Id
|
|
*/
|
|
/**
|
|
* @param {T} t
|
|
* @template T
|
|
*/
|
|
function Zet(t) {
|
|
/** @type {T} */
|
|
this.u
|
|
this.t = t
|
|
}
|
|
/**
|
|
* @param {T} v
|
|
* @param {Id<T>} 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
|