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
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import './init';
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import {CUSTOM} from '../src/custom_token';
|
||||
import {CompWithProviders} from '../src/features';
|
||||
import {MainModule} from '../src/module';
|
||||
|
||||
import {createComponent, createModule} from './util';
|
||||
|
||||
describe('template codegen output', () => {
|
||||
it('should support forwardRef with useValue in components', () => {
|
||||
const compFixture = createComponent(CompWithProviders);
|
||||
expect(compFixture.componentInstance.ctxProp).toBe('strValue');
|
||||
});
|
||||
|
||||
it('should support forwardRef with useValue in modules', () => {
|
||||
const modRef = createModule();
|
||||
expect(modRef.injector.get(CUSTOM).name).toBe('some name');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user