(
metatypeToReplace: ModuleMetatype,
newMetatype: ModuleMetatype,
scope: ModuleScope,
)
| 127 | } |
| 128 | |
| 129 | public async replaceModule( |
| 130 | metatypeToReplace: ModuleMetatype, |
| 131 | newMetatype: ModuleMetatype, |
| 132 | scope: ModuleScope, |
| 133 | ): Promise< |
| 134 | | { |
| 135 | moduleRef: Module; |
| 136 | inserted: boolean; |
| 137 | } |
| 138 | | undefined |
| 139 | > { |
| 140 | // In DependenciesScanner#scanForModules we already check for undefined or invalid modules |
| 141 | // We still need to catch the edge-case of `forwardRef(() => undefined)` |
| 142 | if (!metatypeToReplace || !newMetatype) { |
| 143 | throw new UndefinedForwardRefException(scope); |
| 144 | } |
| 145 | |
| 146 | const { token } = await this.moduleCompiler.compile(metatypeToReplace); |
| 147 | const { type, dynamicMetadata } = |
| 148 | await this.moduleCompiler.compile(newMetatype); |
| 149 | |
| 150 | return { |
| 151 | moduleRef: await this.setModule( |
| 152 | { |
| 153 | token, |
| 154 | type, |
| 155 | dynamicMetadata, |
| 156 | }, |
| 157 | scope, |
| 158 | ), |
| 159 | inserted: false, |
| 160 | }; |
| 161 | } |
| 162 | |
| 163 | private async setModule( |
| 164 | { token, dynamicMetadata, type }: ModuleFactory, |
no test coverage detected