66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { NgtscProgram } from '../../../../../compiler-cli/src/ngtsc/program' ;
109import { FileSystem } from '../../../../../compiler-cli/src/ngtsc/file_system' ;
1110import { confirmAsSerializable , Serializable } from '../../../utils/tsurge/helpers/serializable' ;
1211import { BaseProgramInfo , ProgramInfo } from '../../../utils/tsurge/program_info' ;
@@ -26,24 +25,23 @@ import {InheritanceGraph} from './utils/inheritance_graph';
2625import { executeMigrationPhase } from './phase_migrate' ;
2726import { filterIncompatibilitiesForBestEffortMode } from './best_effort_mode' ;
2827import { createNgtscProgram } from '../../../utils/tsurge/helpers/ngtsc_program' ;
28+ import assert from 'assert' ;
2929
3030/**
3131 * Tsurge migration for migrating Angular `@Input()` declarations to
3232 * signal inputs, with support for batch execution.
3333 */
3434export class SignalInputMigration extends TsurgeComplexMigration <
3535 CompilationUnitData ,
36- CompilationUnitData ,
37- NgtscProgram ,
38- AnalysisProgramInfo
36+ CompilationUnitData
3937> {
4038 upgradeAnalysisPhaseToAvoidBatch = false ;
4139 upgradedAnalysisPhaseResults : Replacement [ ] | null = null ;
4240
4341 bestEffortMode = false ;
4442
4543 // Override the default ngtsc program creation, to add extra flags.
46- override createProgram ( tsconfigAbsPath : string , fs ?: FileSystem ) : BaseProgramInfo < NgtscProgram > {
44+ override createProgram ( tsconfigAbsPath : string , fs ?: FileSystem ) : BaseProgramInfo {
4745 return createNgtscProgram ( tsconfigAbsPath , fs , {
4846 _enableTemplateTypeChecker : true ,
4947 _compilePoisonedComponents : true ,
@@ -57,23 +55,20 @@ export class SignalInputMigration extends TsurgeComplexMigration<
5755 }
5856
5957 // Extend the program info with the analysis information we need in every phase.
60- override prepareProgram ( baseInfo : BaseProgramInfo < NgtscProgram > ) : AnalysisProgramInfo {
61- const info = super . prepareProgram ( baseInfo ) ;
58+ prepareAnalysisDeps ( info : ProgramInfo ) : AnalysisProgramInfo {
59+ assert ( info . ngCompiler !== null , 'Expected `NgCompiler` to be configured.' ) ;
6260 return {
6361 ...info ,
64- ...prepareAnalysisInfo (
65- info . program . getTsProgram ( ) ,
66- info . program . compiler ,
67- info . programAbsoluteRootPaths ,
68- ) ,
62+ ...prepareAnalysisInfo ( info . program , info . ngCompiler , info . programAbsoluteRootPaths ) ,
6963 } ;
7064 }
7165
72- override async analyze ( analysisDeps : AnalysisProgramInfo ) {
66+ override async analyze ( info : ProgramInfo ) {
67+ const analysisDeps = this . prepareAnalysisDeps ( info ) ;
7368 const { metaRegistry} = analysisDeps ;
7469 const knownInputs = new KnownInputs ( ) ;
7570 const result = new MigrationResult ( ) ;
76- const host = createMigrationHost ( analysisDeps ) ;
71+ const host = createMigrationHost ( info ) ;
7772
7873 const { inheritanceGraph} = executeAnalysisPhase ( host , knownInputs , result , analysisDeps ) ;
7974 pass4__checkInheritanceOfInputs ( host , inheritanceGraph , metaRegistry , knownInputs ) ;
@@ -86,11 +81,12 @@ export class SignalInputMigration extends TsurgeComplexMigration<
8681 // Non-batch mode!
8782 if ( this . upgradeAnalysisPhaseToAvoidBatch ) {
8883 const merged = await this . merge ( [ unitData ] ) ;
89- const replacements = await this . migrate ( merged , analysisDeps , {
84+ const replacements = await this . migrate ( merged , info , {
9085 knownInputs,
9186 result,
9287 host,
9388 inheritanceGraph,
89+ analysisDeps,
9490 } ) ;
9591
9692 // Expose the upgraded analysis stage results.
@@ -106,18 +102,19 @@ export class SignalInputMigration extends TsurgeComplexMigration<
106102
107103 override async migrate (
108104 globalMetadata : CompilationUnitData ,
109- analysisDeps : AnalysisProgramInfo ,
105+ info : ProgramInfo ,
110106 nonBatchData ?: {
111107 knownInputs : KnownInputs ;
112108 result : MigrationResult ;
113109 host : MigrationHost ;
114110 inheritanceGraph : InheritanceGraph ;
111+ analysisDeps : AnalysisProgramInfo ;
115112 } ,
116113 ) : Promise < Replacement [ ] > {
117114 const knownInputs = nonBatchData ?. knownInputs ?? new KnownInputs ( ) ;
118115 const result = nonBatchData ?. result ?? new MigrationResult ( ) ;
119- const host = nonBatchData ?. host ?? createMigrationHost ( analysisDeps ) ;
120- const { metaRegistry } = analysisDeps ;
116+ const host = nonBatchData ?. host ?? createMigrationHost ( info ) ;
117+ const analysisDeps = nonBatchData ?. analysisDeps ?? this . prepareAnalysisDeps ( info ) ;
121118 let inheritanceGraph : InheritanceGraph ;
122119
123120 // Can't re-use analysis structures, so re-build them.
@@ -129,7 +126,7 @@ export class SignalInputMigration extends TsurgeComplexMigration<
129126 inheritanceGraph = nonBatchData . inheritanceGraph ;
130127 }
131128
132- pass4__checkInheritanceOfInputs ( host , inheritanceGraph , metaRegistry , knownInputs ) ;
129+ pass4__checkInheritanceOfInputs ( host , inheritanceGraph , analysisDeps . metaRegistry , knownInputs ) ;
133130 if ( this . bestEffortMode ) {
134131 filterIncompatibilitiesForBestEffortMode ( knownInputs ) ;
135132 }
@@ -140,7 +137,7 @@ export class SignalInputMigration extends TsurgeComplexMigration<
140137 }
141138}
142139
143- function createMigrationHost ( info : ProgramInfo < NgtscProgram > ) : MigrationHost {
140+ function createMigrationHost ( info : ProgramInfo ) : MigrationHost {
144141 return new MigrationHost (
145142 /* projectDir */ info . projectDirAbsPath ,
146143 /* isMigratingCore */ false ,
0 commit comments