fix(compiler): work well with forwardRef with useValue / useFactory
The new expression lowering lowers everything after `useValue` / `useFactory` into a separate exported variable. If the value was a `forwardRef`, this was passed to the runtime and resulted in errors. This change unwraps `forwardRef`s during runtime again. Note: we can’t unwrap the `forwardRef` into an exported variable during compile time, as this would defeat the purpose of the `forwardRef` in referring to something that can’t be referred to at this position.
This commit is contained in:
committed by
Victor Berchet
parent
e31a76ce24
commit
1dacae2c3c
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ApplicationRef, NgModule} from '@angular/core';
|
||||
import {ApplicationRef, NgModule, forwardRef} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {MATERIAL_SANITY_CHECKS, MdButtonModule} from '@angular/material';
|
||||
import {ServerModule} from '@angular/platform-server';
|
||||
@@ -68,7 +68,7 @@ export {SomeModule as JitSummariesSomeModule} from './jit_summaries';
|
||||
],
|
||||
providers: [
|
||||
SomeService,
|
||||
{provide: CUSTOM, useValue: {name: 'some name'}},
|
||||
{provide: CUSTOM, useValue: forwardRef(() => ({name: 'some name'}))},
|
||||
// disable sanity check for material because it throws an error when used server-side
|
||||
// see https://github.com/angular/material2/issues/6292
|
||||
{provide: MATERIAL_SANITY_CHECKS, useValue: false},
|
||||
|
||||
Reference in New Issue
Block a user