mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-16 07:13:43 -05:00
Fix commonjs export= merging (#27368)
I'm surprised we haven't seen more of this; I suspect it's because the mixed `module.exports=` + `export.foo=` pattern isn't that common. However, it'll happen any time that the exported symbol is unknown; getCommonJsExportEquals blithely clones unknownSymbol and proceeds to stick the `exports.foo=` properties onto it. This causes problems later, because the compiler checks for unknownSymbol with `===`. The fix is to not stick properties onto a clone of unknownSymbol. This makes the correct errors appear and removes the crash.
This commit is contained in:
committed by
GitHub
parent
f4a643fdf0
commit
b77cb2ac45
@@ -2340,7 +2340,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getCommonJsExportEquals(exported: Symbol | undefined, moduleSymbol: Symbol): Symbol | undefined {
|
||||
if (!exported || moduleSymbol.exports!.size === 1) {
|
||||
if (!exported || exported === unknownSymbol || moduleSymbol.exports!.size === 1) {
|
||||
return exported;
|
||||
}
|
||||
const merged = cloneSymbol(exported);
|
||||
|
||||
Reference in New Issue
Block a user