Skip to content

Commit

Permalink
Add Variable to HasExports (#24871)
Browse files Browse the repository at this point in the history
JS containers are variables, but may have exports just like classes and
modules.
  • Loading branch information
sandersn authored Jun 11, 2018
1 parent d8f6f30 commit 923a8aa
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3467,7 +3467,7 @@ namespace ts {

ExportHasLocal = Function | Class | Enum | ValueModule,

HasExports = Class | Enum | Module,
HasExports = Class | Enum | Module | Variable,
HasMembers = Class | Interface | TypeLiteral | ObjectLiteral,

BlockScoped = BlockScopedVariable | Class | Enum,
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ declare namespace ts {
AliasExcludes = 2097152,
ModuleMember = 2623475,
ExportHasLocal = 944,
HasExports = 1952,
HasExports = 1955,
HasMembers = 6240,
BlockScoped = 418,
PropertyOrAccessor = 98308,
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ declare namespace ts {
AliasExcludes = 2097152,
ModuleMember = 2623475,
ExportHasLocal = 944,
HasExports = 1952,
HasExports = 1955,
HasMembers = 6240,
BlockScoped = 418,
PropertyOrAccessor = 98308,
Expand Down
21 changes: 21 additions & 0 deletions tests/baselines/reference/moduleExportAlias5.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
=== tests/cases/conformance/salsa/bug24754.js ===
// #24754
const webpack = function (){
>webpack : Symbol(webpack, Decl(bug24754.js, 1, 5))
}
exports = module.exports = webpack;
>exports : Symbol("tests/cases/conformance/salsa/bug24754", Decl(bug24754.js, 0, 0))
>module : Symbol(export=, Decl(bug24754.js, 3, 9))
>exports : Symbol(export=, Decl(bug24754.js, 3, 9))
>webpack : Symbol(webpack, Decl(bug24754.js, 1, 5))

exports.version = 1001;
>exports.version : Symbol(version, Decl(bug24754.js, 3, 35))
>exports : Symbol(version, Decl(bug24754.js, 3, 35))
>version : Symbol(version, Decl(bug24754.js, 3, 35))

webpack.WebpackOptionsDefaulter = 1111;
>webpack.WebpackOptionsDefaulter : Symbol(webpack.WebpackOptionsDefaulter, Decl(bug24754.js, 4, 23))
>webpack : Symbol(webpack, Decl(bug24754.js, 1, 5))
>WebpackOptionsDefaulter : Symbol(webpack.WebpackOptionsDefaulter, Decl(bug24754.js, 4, 23))

29 changes: 29 additions & 0 deletions tests/baselines/reference/moduleExportAlias5.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
=== tests/cases/conformance/salsa/bug24754.js ===
// #24754
const webpack = function (){
>webpack : { (): void; WebpackOptionsDefaulter: number; }
>function (){} : { (): void; WebpackOptionsDefaulter: number; }
}
exports = module.exports = webpack;
>exports = module.exports = webpack : { (): void; WebpackOptionsDefaulter: number; }
>exports : typeof import("tests/cases/conformance/salsa/bug24754")
>module.exports = webpack : { (): void; WebpackOptionsDefaulter: number; }
>module.exports : any
>module : any
>exports : any
>webpack : { (): void; WebpackOptionsDefaulter: number; }

exports.version = 1001;
>exports.version = 1001 : 1001
>exports.version : number
>exports : typeof import("tests/cases/conformance/salsa/bug24754")
>version : number
>1001 : 1001

webpack.WebpackOptionsDefaulter = 1111;
>webpack.WebpackOptionsDefaulter = 1111 : 1111
>webpack.WebpackOptionsDefaulter : number
>webpack : { (): void; WebpackOptionsDefaulter: number; }
>WebpackOptionsDefaulter : number
>1111 : 1111

11 changes: 11 additions & 0 deletions tests/cases/conformance/salsa/moduleExportAlias5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @checkJs: true
// @allowJS: true
// @noEmit: true
// @Filename: bug24754.js
// #24754
const webpack = function (){
}
exports = module.exports = webpack;
exports.version = 1001;

webpack.WebpackOptionsDefaulter = 1111;

0 comments on commit 923a8aa

Please sign in to comment.