From 99faffb514326f6465b5388bd2eaedd3e2fa5920 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 24 Jan 2025 12:39:36 +0100 Subject: [PATCH] fix(core): ensure type is preserved during HMR Fixes an internal HMR issue where the type might be replaced when swapping out the definition. Externally this is a no-op. --- packages/core/src/render3/hmr.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/core/src/render3/hmr.ts b/packages/core/src/render3/hmr.ts index 283e67e40af8..3dcf7fa56572 100644 --- a/packages/core/src/render3/hmr.ts +++ b/packages/core/src/render3/hmr.ts @@ -118,6 +118,11 @@ function mergeWithExistingDefinition( // Preserve the old `setInput` function, because it has some state. // This is fine, because the component instance is preserved as well. setInput: clone.setInput, + + // Externally this is redundant since we redeclare the definition using the original type. + // Internally we may receive a definition with an alternate, but identical, type so we have + // to ensure that the original one is preserved. + type: clone.type, }); ngDevMode && assertEqual(replacement, currentDef, 'Expected definition to be merged in place');