Skip to content

Commit

Permalink
docs(docs-infra): changed default type to object (angular#58289)
Browse files Browse the repository at this point in the history
By API returned type is object, not any, rephrase docs and TIP

Fixes angular#58273

docs: change type from object to Object

Change the typo from object to Object

Co-authored-by: Matthieu Riegler <[email protected]>

PR Close angular#58289
  • Loading branch information
vladboisa authored and thePunderWoman committed Nov 22, 2024
1 parent 893886d commit 1bdc3f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions adev/src/content/guide/http/making-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ http.get<Config>('/api/config').subscribe(config => {
});
</docs-code>

Note the generic type argument which specifies that the data returned by the server will be of type `Config`. This argument is optional, and if you omit it then the returned data will have type `any`.
Note the generic type argument which specifies that the data returned by the server will be of type `Config`. This argument is optional, and if you omit it then the returned data will have type `Object`.

Tip: If the data has an unknown shape, then a safer alternative to `any` is to use the `unknown` type as the response type.
Tip: When dealing with data of uncertain structure and potential `undefined` or `null` values, consider using the `unknown` type instead of `Object` as the response type.

CRITICAL: The generic type of request methods is a type **assertion** about the data returned by the server. `HttpClient` does not verify that the actual return data matches this type.

Expand Down

0 comments on commit 1bdc3f1

Please sign in to comment.