Skip to content

Commit 923a8aa

Browse files
authored
Add Variable to HasExports (microsoft#24871)
JS containers are variables, but may have exports just like classes and modules.
1 parent d8f6f30 commit 923a8aa

File tree

6 files changed

+64
-3
lines changed

6 files changed

+64
-3
lines changed

src/compiler/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3467,7 +3467,7 @@ namespace ts {
34673467

34683468
ExportHasLocal = Function | Class | Enum | ValueModule,
34693469

3470-
HasExports = Class | Enum | Module,
3470+
HasExports = Class | Enum | Module | Variable,
34713471
HasMembers = Class | Interface | TypeLiteral | ObjectLiteral,
34723472

34733473
BlockScoped = BlockScopedVariable | Class | Enum,

tests/baselines/reference/api/tsserverlibrary.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ declare namespace ts {
20712071
AliasExcludes = 2097152,
20722072
ModuleMember = 2623475,
20732073
ExportHasLocal = 944,
2074-
HasExports = 1952,
2074+
HasExports = 1955,
20752075
HasMembers = 6240,
20762076
BlockScoped = 418,
20772077
PropertyOrAccessor = 98308,

tests/baselines/reference/api/typescript.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ declare namespace ts {
20712071
AliasExcludes = 2097152,
20722072
ModuleMember = 2623475,
20732073
ExportHasLocal = 944,
2074-
HasExports = 1952,
2074+
HasExports = 1955,
20752075
HasMembers = 6240,
20762076
BlockScoped = 418,
20772077
PropertyOrAccessor = 98308,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/conformance/salsa/bug24754.js ===
2+
// #24754
3+
const webpack = function (){
4+
>webpack : Symbol(webpack, Decl(bug24754.js, 1, 5))
5+
}
6+
exports = module.exports = webpack;
7+
>exports : Symbol("tests/cases/conformance/salsa/bug24754", Decl(bug24754.js, 0, 0))
8+
>module : Symbol(export=, Decl(bug24754.js, 3, 9))
9+
>exports : Symbol(export=, Decl(bug24754.js, 3, 9))
10+
>webpack : Symbol(webpack, Decl(bug24754.js, 1, 5))
11+
12+
exports.version = 1001;
13+
>exports.version : Symbol(version, Decl(bug24754.js, 3, 35))
14+
>exports : Symbol(version, Decl(bug24754.js, 3, 35))
15+
>version : Symbol(version, Decl(bug24754.js, 3, 35))
16+
17+
webpack.WebpackOptionsDefaulter = 1111;
18+
>webpack.WebpackOptionsDefaulter : Symbol(webpack.WebpackOptionsDefaulter, Decl(bug24754.js, 4, 23))
19+
>webpack : Symbol(webpack, Decl(bug24754.js, 1, 5))
20+
>WebpackOptionsDefaulter : Symbol(webpack.WebpackOptionsDefaulter, Decl(bug24754.js, 4, 23))
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
=== tests/cases/conformance/salsa/bug24754.js ===
2+
// #24754
3+
const webpack = function (){
4+
>webpack : { (): void; WebpackOptionsDefaulter: number; }
5+
>function (){} : { (): void; WebpackOptionsDefaulter: number; }
6+
}
7+
exports = module.exports = webpack;
8+
>exports = module.exports = webpack : { (): void; WebpackOptionsDefaulter: number; }
9+
>exports : typeof import("tests/cases/conformance/salsa/bug24754")
10+
>module.exports = webpack : { (): void; WebpackOptionsDefaulter: number; }
11+
>module.exports : any
12+
>module : any
13+
>exports : any
14+
>webpack : { (): void; WebpackOptionsDefaulter: number; }
15+
16+
exports.version = 1001;
17+
>exports.version = 1001 : 1001
18+
>exports.version : number
19+
>exports : typeof import("tests/cases/conformance/salsa/bug24754")
20+
>version : number
21+
>1001 : 1001
22+
23+
webpack.WebpackOptionsDefaulter = 1111;
24+
>webpack.WebpackOptionsDefaulter = 1111 : 1111
25+
>webpack.WebpackOptionsDefaulter : number
26+
>webpack : { (): void; WebpackOptionsDefaulter: number; }
27+
>WebpackOptionsDefaulter : number
28+
>1111 : 1111
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @checkJs: true
2+
// @allowJS: true
3+
// @noEmit: true
4+
// @Filename: bug24754.js
5+
// #24754
6+
const webpack = function (){
7+
}
8+
exports = module.exports = webpack;
9+
exports.version = 1001;
10+
11+
webpack.WebpackOptionsDefaulter = 1111;

0 commit comments

Comments
 (0)