Skip to content

Commit 2ff8fae

Browse files
authored
Merge pull request microsoft#21900 from Microsoft/fix21620
Fix emit when binder treats exported const as namespace
2 parents 458c12f + c84b7ca commit 2ff8fae

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
@@ -25054,7 +25054,7 @@ namespace ts {
2505425054
// we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the
2505525055
// kinds that we do NOT prefix.
2505625056
const exportSymbol = getMergedSymbol(symbol.exportSymbol);
25057-
if (!prefixLocals && exportSymbol.flags & SymbolFlags.ExportHasLocal) {
25057+
if (!prefixLocals && exportSymbol.flags & SymbolFlags.ExportHasLocal && !(exportSymbol.flags & SymbolFlags.Variable)) {
2505825058
return undefined;
2505925059
}
2506025060
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)