TypeScript/tests/cases/conformance/jsdoc/jsdocTypeReferenceToMergedClass.ts
Nathan Shively-Sanders d892fd408f
Fix expando handling in getTypeReferenceType (#34712)
* Fix expando handling in getTypeReferenceType

getExpandoSymbol looks for the initialiser of a symbol when it is an
expando value (IIFEs, function exprs, class exprs and empty object
literals) and returns the symbol.

Previously, however, it returned the symbol of the initialiser without
merging with the declaration symbol itself. This missed, in particular,
the prototype assignment in the following pattern:

```js
var x = function x() {
  this.y = 1
}
x.prototype = {
  z() { }
}

/** @type {x} */
var xx;
xx.z // missed!
```

getJSDocValueReference had weird try-again code that relied on calling
getTypeOfSymbol, which *does* correctly merge the symbols. This PR
re-removes that code and instead makes getExpandoSymbol call
mergeJSSymbols itself.

* Remove extra newline
2019-10-24 13:12:44 -07:00

16 lines
336 B
TypeScript

// https://github.com/microsoft/TypeScript/issues/34685
// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: jsdocTypeReferenceToMergedClass.js
var Workspace = {}
/** @type {Workspace.Project} */
var p;
p.isServiceProject()
Workspace.Project = function wp() { }
Workspace.Project.prototype = {
isServiceProject() {}
}