diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dba3c8584b1..4fcb0d15a5f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4110,7 +4110,7 @@ namespace ts { function getExportSymbolOfValueSymbolIfExported(symbol: Symbol): Symbol; function getExportSymbolOfValueSymbolIfExported(symbol: Symbol | undefined): Symbol | undefined; function getExportSymbolOfValueSymbolIfExported(symbol: Symbol | undefined): Symbol | undefined { - return getMergedSymbol(symbol && (symbol.flags & SymbolFlags.ExportValue) !== 0 ? symbol.exportSymbol : symbol); + return getMergedSymbol(symbol && (symbol.flags & SymbolFlags.ExportValue) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol: Symbol): boolean { diff --git a/tests/baselines/reference/reExportJsFromTs.js b/tests/baselines/reference/reExportJsFromTs.js new file mode 100644 index 00000000000..6879d65e0b9 --- /dev/null +++ b/tests/baselines/reference/reExportJsFromTs.js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/salsa/reExportJsFromTs.ts] //// + +//// [constants.js] +module.exports = { + str: 'x', +}; + +//// [constants.ts] +import * as tsConstants from "../lib/constants"; +export { tsConstants }; + +//// [constants.js] +module.exports = { + str: 'x' +}; +//// [constants.js] +"use strict"; +exports.__esModule = true; +exports.tsConstants = void 0; +var tsConstants = require("../lib/constants"); +exports.tsConstants = tsConstants; diff --git a/tests/baselines/reference/reExportJsFromTs.symbols b/tests/baselines/reference/reExportJsFromTs.symbols new file mode 100644 index 00000000000..eddddb5aed5 --- /dev/null +++ b/tests/baselines/reference/reExportJsFromTs.symbols @@ -0,0 +1,18 @@ +=== /lib/constants.js === +module.exports = { +>module.exports : Symbol(module.exports, Decl(constants.js, 0, 0)) +>module : Symbol(export=, Decl(constants.js, 0, 0)) +>exports : Symbol(export=, Decl(constants.js, 0, 0)) + + str: 'x', +>str : Symbol(str, Decl(constants.js, 0, 18)) + +}; + +=== /src/constants.ts === +import * as tsConstants from "../lib/constants"; +>tsConstants : Symbol(tsConstants, Decl(constants.ts, 0, 6)) + +export { tsConstants }; +>tsConstants : Symbol(tsConstants, Decl(constants.ts, 1, 8)) + diff --git a/tests/baselines/reference/reExportJsFromTs.types b/tests/baselines/reference/reExportJsFromTs.types new file mode 100644 index 00000000000..130fc00f1ae --- /dev/null +++ b/tests/baselines/reference/reExportJsFromTs.types @@ -0,0 +1,21 @@ +=== /lib/constants.js === +module.exports = { +>module.exports = { str: 'x',} : { str: string; } +>module.exports : { str: string; } +>module : { exports: { str: string; }; } +>exports : { str: string; } +>{ str: 'x',} : { str: string; } + + str: 'x', +>str : string +>'x' : "x" + +}; + +=== /src/constants.ts === +import * as tsConstants from "../lib/constants"; +>tsConstants : { str: string; } + +export { tsConstants }; +>tsConstants : { str: string; } + diff --git a/tests/cases/conformance/salsa/reExportJsFromTs.ts b/tests/cases/conformance/salsa/reExportJsFromTs.ts new file mode 100644 index 00000000000..860692e393a --- /dev/null +++ b/tests/cases/conformance/salsa/reExportJsFromTs.ts @@ -0,0 +1,11 @@ +// @allowJs: true +// @outDir: out + +// @Filename: /lib/constants.js +module.exports = { + str: 'x', +}; + +// @Filename: /src/constants.ts +import * as tsConstants from "../lib/constants"; +export { tsConstants }; \ No newline at end of file