Is it necessary to set the return value of the function in Angular?

such as

getHeroes (): Observable < Hero [] > {
return this.http.get < Hero [] > (this.heroesUrl)
}

can I just write it this way?

getHeroes () {
return this.http.get < Hero [] > (this.heroesUrl)
}

is it necessary to give < Hero [] > after get? What"s the point?

I see that some code will get the data of the json class from an api
and then write directly:

private headers = new HttpHeaders (). Set ("Content-Type"," application/json");
/ / does not provide the return of the function and does not give anything after the get
getHeroes () {
return this.http.get (this.myurl, {headers:this.headers})
}

is it because the data types to be accepted are not defined in angular in advance?

Thank you for answering!

Feb.26,2021

to talk about this in detail, you may need to know what weakly typed languages and strongly typed languages are. Google it yourself

to put it simply, specifying the type helps to be tool-friendly, and development tools can use definitions for real-time detection and IntelliSense, giving feedback during the code writing phase. For example, when developing typescript with vs code, enter the specified type of variable. Type member perception at symbol

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9e321-19bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9e321-19bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?