Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tour of Heroes (toh-pt6): Misleading information on HTTP request response type #34746

Closed
pepiku opened this issue Jan 12, 2020 · 3 comments
Closed

Comments

@pepiku
Copy link

@pepiku pepiku commented Jan 12, 2020

馃摎 Docs or angular.io bug report

Description

In section "HttpClient.get() returns response data" the tutorial says:
"HttpClient.get() returns the body of the response as an untyped JSON object by default. Applying the optional type specifier, <Hero[]> , gives you a typed result object."

For me this sentence was very misleading when learning Angular. I was expecting to be able to provide a class type and would get an object instance including all the members of the class - specifically I would be able to call mehods defined in the class.

The class type is only used for syntax check / code-completion, however, during runtime the object returned by the get() method is a plain javascript object as received with the JSON response from the server, with the prototype being "Object". It does not contain any further members of the class.

The tutorial should explain this in more detail, and if there is any best practices on how to transform from the JSON object to a real typed object, this should also be explained or pointed to.

The functionality/feature that a plain JSON object is returned despite of the type being specified is for example discussed here:
#20770

馃敩 Minimal Reproduction

What's the affected URL?**

https://angular.io/tutorial/toh-pt6#httpclientget-returns-response-data

@ngbot ngbot bot added this to the needsTriage milestone Jan 13, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jan 13, 2020
@kapunahelewong kapunahelewong added this to Pending - Top of backlog in docs Jan 13, 2020
@ajitsinghkaler

This comment has been minimized.

Copy link
Contributor

@ajitsinghkaler ajitsinghkaler commented Jan 13, 2020

@kapunahelewong Can I take this.

@kapunahelewong

This comment has been minimized.

Copy link
Contributor

@kapunahelewong kapunahelewong commented Jan 13, 2020

Certainly, thank you, @ajitsinghkaler!! 馃尭馃挮

@kapunahelewong kapunahelewong moved this from Pending - Top of backlog to Committed - Selected for development in docs Jan 13, 2020
ajitsinghkaler added a commit to ajitsinghkaler/angular that referenced this issue Jan 18, 2020
earlier in the docs it was told that adding typescript's type checking make json response typed so changed docs to say that it adds all typescipt capabilities during compile time

Fixes angular#34746
@kapunahelewong

This comment has been minimized.

Copy link
Contributor

@kapunahelewong kapunahelewong commented Jan 20, 2020

@pepiku does @ajitsinghkaler's PR #34845 clarify it fully for you?

ajitsinghkaler added a commit to ajitsinghkaler/angular that referenced this issue Jan 20, 2020
earlier in the docs it was told that adding typescript's type checking make json response typed so changed docs to say that it adds all typescipt capabilities during compile time

Fixes angular#34746
@matsko matsko closed this in fae5c52 Jan 21, 2020
matsko added a commit that referenced this issue Jan 21, 2020
earlier in the docs it was told that adding typescript's type checking make json response typed so changed docs to say that it adds all typescipt capabilities during compile time

Fixes #34746

PR Close #34845
@kapunahelewong kapunahelewong moved this from Committed - Selected for development to Done in docs Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
docs
Done
4 participants
You can鈥檛 perform that action at this time.