( type: o.WrappedNodeExpr<any>, useType: o.WrappedNodeExpr<any>, unwrapForwardRefs: boolean, )
| 152 | } |
| 153 | |
| 154 | export function delegateToFactory( |
| 155 | type: o.WrappedNodeExpr<any>, |
| 156 | useType: o.WrappedNodeExpr<any>, |
| 157 | unwrapForwardRefs: boolean, |
| 158 | ): o.Expression { |
| 159 | if (type.node === useType.node) { |
| 160 | // The types are the same, so we can simply delegate directly to the type's factory. |
| 161 | // ``` |
| 162 | // factory: type.ɵfac |
| 163 | // ``` |
| 164 | return useType.prop('ɵfac'); |
| 165 | } |
| 166 | |
| 167 | if (!unwrapForwardRefs) { |
| 168 | // The type is not wrapped in a `forwardRef()`, so we create a simple factory function that |
| 169 | // accepts a sub-type as an argument. |
| 170 | // ``` |
| 171 | // factory: function(t) { return useType.ɵfac(t); } |
| 172 | // ``` |
| 173 | return createFactoryFunction(useType); |
| 174 | } |
| 175 | |
| 176 | // The useType is actually wrapped in a `forwardRef()` so we need to resolve that before |
| 177 | // calling its factory. |
| 178 | // ``` |
| 179 | // factory: function(t) { return core.resolveForwardRef(type).ɵfac(t); } |
| 180 | // ``` |
| 181 | const unwrappedType = o.importExpr(Identifiers.resolveForwardRef).callFn([useType]); |
| 182 | return createFactoryFunction(unwrappedType); |
| 183 | } |
| 184 | |
| 185 | function createFactoryFunction(type: o.Expression): o.ArrowFunctionExpr { |
| 186 | const t = new o.FnParam('__ngFactoryType__', o.DYNAMIC_TYPE); |
no test coverage detected
searching dependent graphs…