Fix crash on aliased,exported @enum tag in jsdoc (#36996)

THe code to bind `@enum` and `@typedef` didn't handle the case that the
`@enum` was on a property assignment to an alias of module.exports.
Specifically, `x` needs to be correctly aliased to the file's symbol in
the example below:

```
var x = module.exports = {};
/** @enum {string} */
x.E = {
  A: "A"
};
```
This commit is contained in:
Nathan Shively-Sanders
2020-02-24 16:13:18 -08:00
committed by GitHub
parent 65e7acce58
commit 3e3df8702c
4 changed files with 53 additions and 1 deletions

View File

@@ -2113,7 +2113,9 @@ namespace ts {
container = (declName.parent.expression as PropertyAccessExpression).name;
break;
case AssignmentDeclarationKind.Property:
container = isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression;
container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file
: isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name
: declName.parent.expression;
break;
case AssignmentDeclarationKind.None:
return Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");