mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00: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:
1 parent
6b21c37937
commit
68875dc5c8
1 file changed
+4
-1
@@ -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