Angular WebStorm在访问角度贴图对象时显示错误

Angular WebStorm在访问角度贴图对象时显示错误,angular,typescript,webstorm,Angular,Typescript,Webstorm,在Angular项目中的一个服务中,我调用了map()函数从GitHub API获取返回数据 getUser(username: string) { // RegEx used for String Manipulation return this.http.get('https://api.github.com/users/'.concat(username)) .map(res => res);} 但是,当我尝试这样调用这个方法时 this.githubService.getUse

在Angular项目中的一个服务中,我调用了
map()
函数从GitHub API获取返回数据

getUser(username: string) {
// RegEx used for String Manipulation
return this.http.get('https://api.github.com/users/'.concat(username))
 .map(res => res);}
但是,当我尝试这样调用这个方法时

this.githubService.getUser('dasunpubudumal')
  .subscribe(user => {
    console.log(user.created_at); });
我的WebStorm IDE在created_at属性下显示一条红线。它表示在类型“Object”上不存在创建的TS2339属性。但是,当我运行代码时,它会显示从该端点返回的JSON对象的created_at字段


我做错什么了吗?有什么办法可以消除这个错误吗?我正在使用HttpClient模块从端点进行请求。

找到了答案。在实现该方法时,我没有声明对象的类型

函数应该是这样的

getUser(username: string) {
return this.http.get<User>('https://api.github.com/users/'.concat(username))
 .map(res => res);
getUser(用户名:string){
返回此.http.get('https://api.github.com/users/“.concat(用户名))
.map(res=>res);
}