Skip to content

Commit 6c1c21f

Browse files
committed
Fix emit when binder treats exported const as namespace
1 parent 1a63767 commit 6c1c21f

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24690,7 +24690,7 @@ namespace ts {
2469024690
// we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the
2469124691
// kinds that we do NOT prefix.
2469224692
const exportSymbol = getMergedSymbol(symbol.exportSymbol);
24693-
if (!prefixLocals && exportSymbol.flags & SymbolFlags.ExportHasLocal) {
24693+
if (!prefixLocals && exportSymbol.flags & SymbolFlags.ExportHasLocal && !(exportSymbol.flags & SymbolFlags.Variable)) {
2469424694
return undefined;
2469524695
}
2469624696
symbol = exportSymbol;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [a.js]
2+
// this is a javascript file...
3+
4+
export const Adapter = {};
5+
6+
Adapter.prop = {};
7+
8+
// comment this out, and it works
9+
Adapter.asyncMethod = function() {}
10+
11+
//// [a.js]
12+
"use strict";
13+
// this is a javascript file...
14+
exports.__esModule = true;
15+
exports.Adapter = {};
16+
exports.Adapter.prop = {};
17+
// comment this out, and it works
18+
exports.Adapter.asyncMethod = function () { };
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/salsa/a.js ===
2+
// this is a javascript file...
3+
4+
export const Adapter = {};
5+
>Adapter : Symbol(Adapter, Decl(a.js, 2, 12), Decl(a.js, 4, 18))
6+
7+
Adapter.prop = {};
8+
>Adapter : Symbol(Adapter, Decl(a.js, 2, 12), Decl(a.js, 4, 18))
9+
10+
// comment this out, and it works
11+
Adapter.asyncMethod = function() {}
12+
>Adapter : Symbol(Adapter, Decl(a.js, 2, 12), Decl(a.js, 4, 18))
13+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/conformance/salsa/a.js ===
2+
// this is a javascript file...
3+
4+
export const Adapter = {};
5+
>Adapter : { [x: string]: any; }
6+
>{} : { [x: string]: any; }
7+
8+
Adapter.prop = {};
9+
>Adapter.prop = {} : {}
10+
>Adapter.prop : any
11+
>Adapter : { [x: string]: any; }
12+
>prop : any
13+
>{} : {}
14+
15+
// comment this out, and it works
16+
Adapter.asyncMethod = function() {}
17+
>Adapter.asyncMethod = function() {} : () => void
18+
>Adapter.asyncMethod : any
19+
>Adapter : { [x: string]: any; }
20+
>asyncMethod : any
21+
>function() {} : () => void
22+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @Filename: a.js
4+
// @outDir: dist
5+
// this is a javascript file...
6+
7+
export const Adapter = {};
8+
9+
Adapter.prop = {};
10+
11+
// comment this out, and it works
12+
Adapter.asyncMethod = function() {}

0 commit comments

Comments
 (0)