56731f624a
Static methods that return a type of ModuleWithProviders currently do not have to specify a type because the generic falls back to any. This is problematic because the type of the actual module being returned is not present in the type information. Since Ivy uses d.ts files exclusively for downstream packages (rather than metadata.json files, for example), we no longer have the type of the actual module being created. For this reason, a generic type should be added for ModuleWithProviders that specifies the module type. This will be required for all users in v10, but will only be necessary for users of Ivy in v9. PR Close #33217 |
||
---|---|---|
.. | ||
BUILD.bazel | ||
README.md | ||
collector.ts | ||
index.ts | ||
transform.ts | ||
util.ts |
README.md
ModuleWithProviders migration
ModuleWithProviders
type will not default to the any
type for its generic in a future version of Angular.
This migration adds a generic to any ModuleWithProvider
types found.
Before
import { NgModule, ModuleWithProviders } from '@angular/core';
@NgModule({})
export class MyModule {
static forRoot(): ModuleWithProviders {
ngModule: MyModule
}
}
After
import { NgModule, ModuleWithProviders } from '@angular/core';
@NgModule({})
export class MyModule {
static forRoot(): ModuleWithProviders<MyModule> {
ngModule: MyModule
}
}