Skip to content

Commit 767a22e

Browse files
karangwattcos
authored andcommitted
docs(core): remove v10 mention from @Injectable warning (angular#37383)
In v9, we started showing a console warning when instantiating a token that inherited its @Injectable decorator rather than providing its own. This warning said that the pattern would become an error in v10. However, we have decided to wait until at least v11 to throw in this case, so this commit updates the warning to be less prescriptive about the exact version when the pattern will no longer be supported. PR Close angular#37383
1 parent 005b4b4 commit 767a22e

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

packages/core/src/di/interface/defs.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ function getOwnDefinition<T>(type: any, def: ɵɵInjectableDef<T>): ɵɵInjectab
217217
*
218218
* @param type A type which may have `ɵprov`, via inheritance.
219219
*
220-
* @deprecated Will be removed in v10, where an error will occur in the scenario if we find the
221-
* `ɵprov` on an ancestor only.
220+
* @deprecated Will be removed in a future version of Angular, where an error will occur in the
221+
* scenario if we find the `ɵprov` on an ancestor only.
222222
*/
223223
export function getInheritedInjectableDef<T>(type: any): ɵɵInjectableDef<T>|null {
224224
// See `jit/injectable.ts#compileInjectable` for context on NG_PROV_DEF_FALLBACK.
@@ -233,7 +233,8 @@ export function getInheritedInjectableDef<T>(type: any): ɵɵInjectableDef<T>|nu
233233
console.warn(
234234
`DEPRECATED: DI is instantiating a token "${
235235
typeName}" that inherits its @Injectable decorator but does not provide one itself.\n` +
236-
`This will become an error in v10. Please add @Injectable() to the "${typeName}" class.`);
236+
`This will become an error in a future version of Angular. Please add @Injectable() to the "${
237+
typeName}" class.`);
237238
return def;
238239
} else {
239240
return null;

packages/core/src/di/jit/injectable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function compileInjectable(type: Type<any>, srcMeta?: Injectable): void {
4646
// undecorated parent class. We work around it by defining a method which should be used
4747
// as a fallback. This should only be a problem in JIT mode, because in AOT TypeScript
4848
// seems to have a workaround for static properties. When inheriting from an undecorated
49-
// parent is no longer supported in v10, this can safely be removed.
49+
// parent is no longer supported (v11 or later), this can safely be removed.
5050
if (!type.hasOwnProperty(NG_PROV_DEF_FALLBACK)) {
5151
(type as any)[NG_PROV_DEF_FALLBACK] = () => (type as any)[NG_PROV_DEF];
5252
}

packages/core/test/acceptance/di_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ describe('di', () => {
10301030
if (ivyEnabled) {
10311031
expect(warnSpy).toHaveBeenCalledWith(
10321032
`DEPRECATED: DI is instantiating a token "SubSubClass" that inherits its @Injectable decorator but does not provide one itself.\n` +
1033-
`This will become an error in v10. Please add @Injectable() to the "SubSubClass" class.`);
1033+
`This will become an error in a future version of Angular. Please add @Injectable() to the "SubSubClass" class.`);
10341034
}
10351035
});
10361036

@@ -1061,7 +1061,7 @@ describe('di', () => {
10611061
if (ivyEnabled) {
10621062
expect(warnSpy).toHaveBeenCalledWith(
10631063
`DEPRECATED: DI is instantiating a token "MyRootService" that inherits its @Injectable decorator but does not provide one itself.\n` +
1064-
`This will become an error in v10. Please add @Injectable() to the "MyRootService" class.`);
1064+
`This will become an error in a future version of Angular. Please add @Injectable() to the "MyRootService" class.`);
10651065
}
10661066
});
10671067

0 commit comments

Comments
 (0)