我在 TS 中有简单的课程:
export class TestObj
{
public name:string;
public id:number;
public example:string;
}
和简单的服务:
@Injectable()
export class SimpleService
{
private testObj:TestObj = new TestObj();
public constructor(@Inject(Http) private http:Http){}
public getTestObj():void
{
this.http.get("/rest/test2").map(res => res.json())
.do(data => console.log(<TestObj> data))
.catch(resp => Observable.throw(resp.json().error))
.subscribe(tobj => {
this.tobj = tobj;
console.log(this.tobj);
}, error => {log.error(error)})
}
如果我在 getTestObj() 之前在控制台日志 SimpleService.testObj 中打印,我看到了
<TestObj>
,但如果我将运行 getTest,日志将是
<Object>
<Object>
是角虫吗?还是打字稿错误?