Skip to content

Commit ff772d7

Browse files
atscottAndrewKushnir
authored andcommitted
fix(core): fix typing on injector.get to omit 'any' (angular#60202)
This commit further restricts the deprecated type on injector.get to exclude all but `string`. Progresses towards angular#48408 BREAKING CHANGE: The `any` overload has been removed from `injector.get`. It now only supports `ProviderToken<T>` and (deprecated since v4) `string`. PR Close angular#60202
1 parent 0cff9a1 commit ff772d7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

goldens/public-api/core/index.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ export abstract class EnvironmentInjector implements Injector {
695695
// @deprecated
696696
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
697697
// @deprecated (undocumented)
698-
abstract get(token: any, notFoundValue?: any): any;
698+
abstract get<T>(token: string | ProviderToken<T>, notFoundValue?: any): any;
699699
// @deprecated
700700
abstract runInContext<ReturnT>(fn: () => ReturnT): ReturnT;
701701
}
@@ -966,7 +966,7 @@ export abstract class Injector {
966966
// @deprecated
967967
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
968968
// @deprecated (undocumented)
969-
abstract get(token: any, notFoundValue?: any): any;
969+
abstract get<T>(token: string | ProviderToken<T>, notFoundValue?: any): any;
970970
// (undocumented)
971971
static NULL: Injector;
972972
// (undocumented)

packages/core/src/di/injector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export abstract class Injector {
9494
* @deprecated from v4.0.0 use ProviderToken<T>
9595
* @suppress {duplicate}
9696
*/
97-
abstract get(token: any, notFoundValue?: any): any;
97+
abstract get<T>(token: string | ProviderToken<T>, notFoundValue?: any): any;
9898

9999
/**
100100
* @deprecated from v5 use the new signature Injector.create(options)

packages/core/src/di/r3_injector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export abstract class EnvironmentInjector implements Injector {
163163
* @deprecated from v4.0.0 use ProviderToken<T>
164164
* @suppress {duplicate}
165165
*/
166-
abstract get(token: any, notFoundValue?: any): any;
166+
abstract get<T>(token: string | ProviderToken<T>, notFoundValue?: any): any;
167167

168168
/**
169169
* Runs the given function in the context of this `EnvironmentInjector`.

0 commit comments

Comments
 (0)