Renato Wagner Renato Wagner - 1 year ago 88
TypeScript Question

About typescript with es6. What I do, please?

I got this error:

[0] app/components/pessoas/detail/PessoaDetailComponent.ts(27,35): error TS2339: Property 'pessoa' does not exist on type '{}'.


export class PessoaDetailComponent
pessoa: any;

constructor(private _api: Api, private _params: RouteParams)
(res) => {
//line 27// this.pessoa = res.pessoa;
(error) => {

Answer Source

This is a type related issue. For whatever reason, typescript thinks res is of type {} and thus complains that pessoa doesn't exist on the type


(res: any) => {
  this.pessoa = res.pessoa;

or use the appropriate type if you know it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download