Skip to content

Commit 20cc3ab

Browse files
karaalxhub
authored andcommitted
refactor(core): make generic mandatory for ModuleWithProviders (angular#36892)
In v9, we deprecated the use of ModuleWithProviders without a generic. In v10, we will be requiring the generic when using ModuleWithProviders. You can read more about the reasoning behind this change in the migration guide: http://v9.angular.io/guide/migration-module-with-providers PR Close angular#36892
1 parent 420b9be commit 20cc3ab

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

aio/content/examples/ngmodules/src/app/greeting/greeting.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class GreetingModule {
2323
// #enddocregion ctor
2424

2525
// #docregion for-root
26-
static forRoot(config: UserServiceConfig): ModuleWithProviders {
26+
static forRoot(config: UserServiceConfig): ModuleWithProviders<GreetingModule> {
2727
return {
2828
ngModule: GreetingModule,
2929
providers: [

aio/tools/examples/shared/boilerplate/testing/tsconfig.app.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../out-tsc/app",
5-
"types": []
5+
"types": [],
6+
// TODO(FW-2145): turn lib checks back on after fixing in-memory-api and investigating impact of ModuleWithProviders
7+
"skipLibCheck": true
68
},
79
"files": [
810
"src/main.ts",

aio/tools/examples/shared/boilerplate/viewengine/cli/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"lib": [
1818
"es2018",
1919
"dom"
20-
]
20+
],
21+
// TODO(FW-2145): turn lib checks back on after fixing in-memory-api and investigating impact of ModuleWithProviders
22+
"skipLibCheck": true
2123
},
2224
"angularCompilerOptions": {
2325
"enableIvy": false,

aio/tools/examples/shared/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"suppressImplicitAnyIndexErrors": true,
1414
"typeRoots": [
1515
"node_modules/@types"
16-
]
16+
],
17+
// TODO(FW-2145): turn lib checks back on after fixing in-memory-api and investigating impact of ModuleWithProviders
18+
"skipLibCheck": true
1719
},
1820
"include": [
1921
"../../../content/examples/*/e2e-spec.ts"

goldens/public-api/core/core.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ export declare class ModuleWithComponentFactories<T> {
559559
constructor(ngModuleFactory: NgModuleFactory<T>, componentFactories: ComponentFactory<any>[]);
560560
}
561561

562-
export declare interface ModuleWithProviders<T = any /** TODO(alxhub): remove default when callers pass explicit type param */> {
562+
export declare interface ModuleWithProviders<T> {
563563
ngModule: Type<T>;
564564
providers?: Provider[];
565565
}

packages/core/src/metadata/ng_module.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,14 @@ export interface NgModuleDef<T> {
8282
/**
8383
* A wrapper around an NgModule that associates it with the providers.
8484
*
85-
* @param T the module type. In Ivy applications, this must be explicitly
86-
* provided.
85+
* @param T the module type.
8786
*
8887
* Note that using ModuleWithProviders without a generic type is deprecated.
8988
* The generic will become required in a future version of Angular.
9089
*
9190
* @publicApi
9291
*/
93-
export interface ModuleWithProviders<
94-
T = any /** TODO(alxhub): remove default when callers pass explicit type param */> {
92+
export interface ModuleWithProviders<T> {
9593
ngModule: Type<T>;
9694
providers?: Provider[];
9795
}

0 commit comments

Comments
 (0)