* Initial implementation The original test passes but I haven't run any other tests yet, so I assume the world is now broken. * Append constructor function construct sigs Instead of overwriting them * Grab bag of improvements. 1. Mark @class-tagged functions with Class too. 2. Only gather local type parameters of constructor functions. 3. Remove getJSClassType calls with getDeclaredTypeOfSymbol. 4. Add a couple more failing tests. getDeclaredTypeOfClassOrInterface now needs to understand prototype assignment. That's next, I think. * Prototype assignments work now 1. Binder marks prototype assignments as Class now. 2. Checker merges prototype assignments using the same merge code as for functions and their declarations. No more intersections. Many fewer failing tests now. * Mark prototype-property assignments as Class Even if there are no this-property assignments in them. (Then why are you using a class?). * Simplify getJSClassType, remove calls to its guts It's probably not needed because now it's just a conditional call to getDeclaredTypeOfSymbol, and I think most callers already know whether they have a JS constructor function beforehand. * isJSDocConstructor doesn't need to check prototype anymore Because all the properties are merged during getDeclaredTypeOfSymbol. * outer type parameter lookup follow prototype assignment * this-type and -expression support in ctor funcs Pretty cool! * Fix remaining tests * Fix minor lint * Delete now-unused code * Add class flag to nested class declarations Also remove old TODOs
36 lines
647 B
TypeScript
36 lines
647 B
TypeScript
// @allowJs: true
|
|
// @checkJs: true
|
|
// @noEmit: true
|
|
// @Filename: templateTagWithNestedTypeLiteral.js
|
|
|
|
/**
|
|
* @param {T} t
|
|
* @template T
|
|
*/
|
|
function Zet(t) {
|
|
/** @type {T} */
|
|
this.u
|
|
this.t = t
|
|
}
|
|
/**
|
|
* @param {T} v
|
|
* @param {object} o
|
|
* @param {T} o.nested
|
|
*/
|
|
Zet.prototype.add = function(v, o) {
|
|
this.u = v || o.nested
|
|
return this.u
|
|
}
|
|
var z = new Zet(1)
|
|
z.t = 2
|
|
z.u = false
|
|
/** @type {number} */
|
|
let answer = z.add(3, { nested: 4 })
|
|
|
|
// lookup in typedef should not crash the compiler, even when the type is unknown
|
|
/**
|
|
* @typedef {Object} A
|
|
* @property {T} value
|
|
*/
|
|
/** @type {A} */
|
|
const options = { value: null };
|