From b9f0720c95c3bfd23b76cf7a9f148bbeb5dbca8e Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Thu, 25 Apr 2019 16:30:50 -0700 Subject: [PATCH] refactor(ivy): undeprecate inject (#30132) PR Close #30132 --- .../core/src/di/injector_compatibility.ts | 30 ++++++++++--------- tools/public_api_guard/core/core.d.ts | 1 - 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/core/src/di/injector_compatibility.ts b/packages/core/src/di/injector_compatibility.ts index 2cb99694a4..1acd952ed6 100644 --- a/packages/core/src/di/injector_compatibility.ts +++ b/packages/core/src/di/injector_compatibility.ts @@ -71,10 +71,23 @@ export function injectInjectorOnly( /** * Generated instruction: Injects a token from the currently active injector. * - * WARNING: This function is meant to be generated by the Ivy compiler, and is not meant for - * developer consumption! + * Must be used in the context of a factory function such as one defined for an + * `InjectionToken`. Throws an error if not called from such a context. * - * https://github.com/angular/angular/blob/master/packages/core/src/render3/DELTA_INSTRUCTIONS.md + * (Additional documentation moved to `inject`, as it is the public API, and an alias for this instruction) + * + * @see inject + * @codeGenApi + */ +export function ɵɵinject(token: Type| InjectionToken): T; +export function ɵɵinject(token: Type| InjectionToken, flags?: InjectFlags): T|null; +export function ɵɵinject(token: Type| InjectionToken, flags = InjectFlags.Default): T| + null { + return (_injectImplementation || injectInjectorOnly)(token, flags); +} + +/** + * Injects a token from the currently active injector. * * Must be used in the context of a factory function such as one defined for an * `InjectionToken`. Throws an error if not called from such a context. @@ -97,17 +110,6 @@ export function injectInjectorOnly( * * @publicApi */ -export function ɵɵinject(token: Type| InjectionToken): T; -export function ɵɵinject(token: Type| InjectionToken, flags?: InjectFlags): T|null; -export function ɵɵinject(token: Type| InjectionToken, flags = InjectFlags.Default): T| - null { - return (_injectImplementation || injectInjectorOnly)(token, flags); -} -/** - * @deprecated in v8, delete after v10. This API should be used only be generated code, and that - * code should now use ɵɵinject instead. - * @publicApi - */ export const inject = ɵɵinject; /** diff --git a/tools/public_api_guard/core/core.d.ts b/tools/public_api_guard/core/core.d.ts index 214218ba97..25ad65f835 100644 --- a/tools/public_api_guard/core/core.d.ts +++ b/tools/public_api_guard/core/core.d.ts @@ -383,7 +383,6 @@ export interface HostListenerDecorator { new (eventName: string, args?: string[]): any; } -/** @deprecated */ export declare const inject: typeof ɵɵinject; export interface Inject {