docs(core): Document TestBed.get deprecation (#32974)

It was replaced by TestBed.inject, documenting such change.

PR Close #32974
This commit is contained in:
Carlos Ortiz García 2019-10-02 14:30:18 -07:00 committed by Matias Niemelä
parent 9de4b1c441
commit 717bace7ba
2 changed files with 17 additions and 3 deletions

View File

@ -29,6 +29,7 @@ v5 - v8
v6 - v9
v7 - v10
v8 - v11
v9 - v12
-->
@ -51,6 +52,7 @@ v8 - v11
| `@angular/core` | [`defineInjectable`](#core) | v11 |
| `@angular/router` | [`loadChildren` string syntax](#loadChildren) | v11 |
| `@angular/router` | [`ActivatedRoute` params and `queryParams` properties](#activatedroute-props) | unspecified |
| `@angular/core/testing` | [`TestBed.get`](#testing) | v12 |
@ -86,6 +88,14 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i
| [`ANALYZE_FOR_ENTRY_COMPONENTS`](api/core/ANALYZE_FOR_ENTRY_COMPONENTS) | none | v9 | See [`ANALYZE_FOR_ENTRY_COMPONENTS`](#entryComponents) |
{@a testing}
### @angular/core/testing
| API | Replacement | Deprecation announced | Notes |
| --- | ----------- | --------------------- | ----- |
| [`TestBed.get`](api/core/testing/TestBed#get) | [`TestBed.inject`](api/core/testing/TestBed#inject) | v9 | Same behavior, but type safe. |
{@a forms}
### @angular/forms

View File

@ -357,11 +357,15 @@ array of the services that you'll test or mock.
Then inject it inside a test by calling `TestBed.inject()` with the service class as the argument.
<div class="alert is-helpful">
**Note:** We used to have `TestBed.get()` instead of `TestBed.inject()`.
The `get` method wasn't type safe, it always returned `any`, and this is error prone.
We decided to migrate to a new function instead of updating the existing one given
the large scale use that would have an immense amount of breaking changes.
</div>
<code-example
path="testing/src/app/demo/demo.testbed.spec.ts"
region="value-service-inject-it">
@ -1065,7 +1069,7 @@ The component injector is a property of the fixture's `DebugElement`.
header="WelcomeComponent's injector">
</code-example>
{@a testbed-get}
{@a testbed-inject}
#### _TestBed.inject()_
@ -3079,8 +3083,8 @@ Here are the most important static methods, in order of likely utility.
<tr>
<td style="vertical-align: top">
{@a testbed-get}
<code>get</code>
{@a testbed-inject}
<code>inject</code>
</td>
<td>