refactor: enable ng update migrations for v10 (#36921)
Enables the `ng update` migrations for v10. Status for individual migrations: **undecorated-classes-with-di**. This migration dealt exlusively with inherited constructors and cases where a derived component was undecorated. In those cases, the migration added `@Directive()` or copied the inherited decorator to the derived class. We don't need to run this migration again because ngtsc throws if constructor is inherited from an undecorated class. Also ngtsc will throw if a NgModule references an undecorated class in the declarations. ***undecorated-classes-with-decorated-fields*** This migration exclusively deals with undecorated classes that use Angular features but are not decorated. Angular features include the use of lifecycle hooks or class fields with Angular decorators, such as `@Input()`. We want to re-run this migration in v10 as we will disable the compatibility code in ngtsc that detects such undecorated classes as `@Directive`. **module-with-providers**: This migration adds an explicit generic type to `ModuleWithProviders`. As of v10, the generic type is required, so we need to re-run the migration again. **renderer-to-renderer2**: We don't need to re-run that migration again as the renderer has been already removed in v9. **missing-injectable**: This migration is exclusively concerned with undecorated providers referenced in an `NgModule`. We should re-run that migration again as we don't have proper backsliding prevention for this yet. We can consider adding an error in ngtsc for v10, or v11. In either way, we should re-run the migration. **dynamic-queries**: We ran this one in v9 to reduce code complexity in projects. Instead of explicitly passing `static: false`, not passing any object literal has the same semantics. We don't need to re-run the migration again since there is no good way to prevent backsliding and we cannot always run this migration for future versions (as some apps might actually intentionally use the explicit `static: false` option). PR Close #36921
This commit is contained in:

committed by
Alex Rickabaugh

parent
4c92cf43cf
commit
0577bf0e3e
@ -64,7 +64,7 @@ describe('Missing injectable migration', () => {
|
||||
}
|
||||
|
||||
function runMigration() {
|
||||
return runner.runSchematicAsync('migration-v9-missing-injectable', {}, tree).toPromise();
|
||||
return runner.runSchematicAsync('migration-v10-missing-injectable', {}, tree).toPromise();
|
||||
}
|
||||
|
||||
describe('NgModule', () => createTests('NgModule', 'providers'));
|
||||
|
@ -230,6 +230,6 @@ describe('ModuleWithProviders migration', () => {
|
||||
}
|
||||
|
||||
function runMigration() {
|
||||
return runner.runSchematicAsync('migration-v9-module-with-providers', {}, tree).toPromise();
|
||||
return runner.runSchematicAsync('migration-v10-module-with-providers', {}, tree).toPromise();
|
||||
}
|
||||
});
|
||||
|
@ -383,7 +383,7 @@ describe('Undecorated classes with decorated fields migration', () => {
|
||||
|
||||
function runMigration() {
|
||||
return runner
|
||||
.runSchematicAsync('migration-v9-undecorated-classes-with-decorated-fields', {}, tree)
|
||||
.runSchematicAsync('migration-v10-undecorated-classes-with-decorated-fields', {}, tree)
|
||||
.toPromise();
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user