refactor(ivy): include generic type for ModuleWithProviders
in .d.ts files (#34235)
The `ModuleWithProviders` type has an optional type parameter that should be specified to indicate what NgModule class will be provided. This enables the Ivy compiler to statically determine the NgModule type from the declaration files. This type parameter will become required in the future, however to aid in the migration the compiler will detect code patterns where using `ModuleWithProviders` as return type is appropriate, in which case it transforms the emitted .d.ts files to include the generic type argument. This should reduce the number of occurrences where `ModuleWithProviders` is referenced without its generic type argument. Resolves FW-389 PR Close #34235
This commit is contained in:
@ -23,6 +23,7 @@ import {IncrementalDriver} from './incremental';
|
||||
import {IndexedComponent, IndexingContext} from './indexer';
|
||||
import {generateAnalysis} from './indexer/src/transform';
|
||||
import {CompoundMetadataReader, CompoundMetadataRegistry, DtsMetadataReader, LocalMetadataRegistry, MetadataReader} from './metadata';
|
||||
import {ModuleWithProvidersScanner} from './modulewithproviders';
|
||||
import {PartialEvaluator} from './partial_evaluator';
|
||||
import {NOOP_PERF_RECORDER, PerfRecorder, PerfTracker} from './perf';
|
||||
import {TypeScriptReflectionHost} from './reflection';
|
||||
@ -31,8 +32,7 @@ import {NgModuleRouteAnalyzer, entryPointKeyFor} from './routing';
|
||||
import {ComponentScopeReader, CompoundComponentScopeReader, LocalModuleScopeRegistry, MetadataDtsModuleScopeResolver} from './scope';
|
||||
import {FactoryGenerator, FactoryInfo, GeneratedShimsHostWrapper, ShimGenerator, SummaryGenerator, TypeCheckShimGenerator, generatedFactoryTransform} from './shims';
|
||||
import {ivySwitchTransform} from './switch';
|
||||
import {IvyCompilation, declarationTransformFactory, ivyTransformFactory} from './transform';
|
||||
import {DtsTransformRegistry} from './transform';
|
||||
import {DtsTransformRegistry, IvyCompilation, declarationTransformFactory, ivyTransformFactory} from './transform';
|
||||
import {aliasTransformFactory} from './transform/src/alias';
|
||||
import {TypeCheckContext, TypeCheckingConfig, typeCheckFilePath} from './typecheck';
|
||||
import {normalizeSeparators} from './util/src/path';
|
||||
@ -71,6 +71,7 @@ export class NgtscProgram implements api.Program {
|
||||
private typeCheckFilePath: AbsoluteFsPath;
|
||||
private modifiedResourceFiles: Set<string>|null;
|
||||
private dtsTransforms: DtsTransformRegistry|null = null;
|
||||
private mwpScanner: ModuleWithProvidersScanner|null = null;
|
||||
|
||||
constructor(
|
||||
rootNames: ReadonlyArray<string>, private options: api.CompilerOptions,
|
||||
@ -623,6 +624,8 @@ export class NgtscProgram implements api.Program {
|
||||
|
||||
this.dtsTransforms = new DtsTransformRegistry();
|
||||
|
||||
this.mwpScanner = new ModuleWithProvidersScanner(this.reflector, evaluator, this.refEmitter);
|
||||
|
||||
// Set up the IvyCompilation, which manages state for the Ivy transformer.
|
||||
const handlers = [
|
||||
new ComponentDecoratorHandler(
|
||||
@ -651,7 +654,7 @@ export class NgtscProgram implements api.Program {
|
||||
return new IvyCompilation(
|
||||
handlers, this.reflector, this.importRewriter, this.incrementalDriver, this.perfRecorder,
|
||||
this.sourceToFactorySymbols, scopeRegistry,
|
||||
this.options.compileNonExportedClasses !== false, this.dtsTransforms);
|
||||
this.options.compileNonExportedClasses !== false, this.dtsTransforms, this.mwpScanner);
|
||||
}
|
||||
|
||||
private get reflector(): TypeScriptReflectionHost {
|
||||
|
Reference in New Issue
Block a user