From 1cca27d823ff72225bb585b19cb952d27eaaa6d0 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sat, 17 Nov 2018 22:36:23 -0800 Subject: [PATCH] fix(ivy): @Inject should not overwrite an existing ngInjectableDef (#27278) There is no test in this diff because I've made a failing test pass. PR Close #27278 --- packages/core/src/render3/jit/injectable.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/src/render3/jit/injectable.ts b/packages/core/src/render3/jit/injectable.ts index 0e77c9a3f5..64a218d3a0 100644 --- a/packages/core/src/render3/jit/injectable.ts +++ b/packages/core/src/render3/jit/injectable.ts @@ -27,6 +27,10 @@ export function compileInjectable(type: Type, srcMeta?: Injectable): void { const meta: Injectable = srcMeta || {providedIn: null}; let def: any = null; + + // if NG_INJECTABLE_DEF is already defined on this class then don't overwrite it + if (type.hasOwnProperty(NG_INJECTABLE_DEF)) return; + Object.defineProperty(type, NG_INJECTABLE_DEF, { get: () => { if (def === null) {