mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-16 07:13:43 -05:00
JS initializers use original valueDecl, not mutated
target's valueDeclaration is set to the source's if it is not present. This makes it incorrect to use getJSInitializerSymbol because it relies on the symbol's valueDeclaration. This fix just saves the original valueDeclaration before mutating and uses that.
This commit is contained in:
@@ -871,6 +871,8 @@ namespace ts {
|
||||
function mergeSymbol(target: Symbol, source: Symbol) {
|
||||
if (!(target.flags & getExcludedSymbolFlags(source.flags)) ||
|
||||
(source.flags | target.flags) & SymbolFlags.JSContainer) {
|
||||
const targetValueDeclaration = target.valueDeclaration;
|
||||
Debug.assert(!!(target.flags & SymbolFlags.Transient));
|
||||
// Javascript static-property-assignment declarations always merge, even though they are also values
|
||||
if (source.flags & SymbolFlags.ValueModule && target.flags & SymbolFlags.ValueModule && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
|
||||
// reset flag when merging instantiated module into value module that has only const enums
|
||||
@@ -894,7 +896,8 @@ namespace ts {
|
||||
}
|
||||
if ((source.flags | target.flags) & SymbolFlags.JSContainer) {
|
||||
const sourceInitializer = getJSInitializerSymbol(source);
|
||||
let targetInitializer = getJSInitializerSymbol(target);
|
||||
const init = getDeclaredJavascriptInitializer(targetValueDeclaration) || getAssignedJavascriptInitializer(targetValueDeclaration);
|
||||
let targetInitializer = init && init.symbol ? init.symbol : target;
|
||||
if (sourceInitializer !== source || targetInitializer !== target) {
|
||||
if (!(targetInitializer.flags & SymbolFlags.Transient)) {
|
||||
const mergedInitializer = getMergedSymbol(targetInitializer);
|
||||
|
||||
Reference in New Issue
Block a user