Fix emit of simple module.exports.C.prototype pattern (#37719)

Extends the fix of #36108 so that the simple example gets correct emit;
the complex test case I came up with still doesn't work correctly, but
the actual code froma #35228 is fixed.
This commit is contained in:
Nathan Shively-Sanders 2020-03-31 14:59:47 -07:00 committed by GitHub
parent a46e9aea10
commit 4dc827e22a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -5648,7 +5648,7 @@ namespace ts {
serializeEnum(symbol, symbolName, modifierFlags);
}
if (symbol.flags & SymbolFlags.Class) {
if (symbol.flags & SymbolFlags.Property) {
if (symbol.flags & SymbolFlags.Property && isBinaryExpression(symbol.valueDeclaration.parent) && isClassExpression(symbol.valueDeclaration.parent.right)) {
// Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members,
// since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property
// _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today.

View File

@ -21,4 +21,6 @@ module.exports.MyClass.prototype = {
//// [jsDeclarationsExportAssignedConstructorFunction.d.ts]
export {};
export class MyClass {
a: () => void;
}