How to Solve “error TS2339: Property ‘<label>’ does not exist on type ‘{}’ “ in angular 5
1 min readFeb 27, 2018
In web application we used object( JSON). so I also tried to pass Json object to a method and used(print) it. but my first try fail because I got error what is mention in main title
this is my code which is my initial code
printFirstName(a={}){
console.log(a.firstName);
}
problem: I getting an error
error TS2339: Property 'firstName' does not exist on type '{}'.
but I called printFistName() function like below
let a={firstName:'Jhone',age:26};
printFirstName(a);
Solution: I changed my printFirstName method “a.firstName” to “a[‘firstName’]” . This solve my error.
printFirstName(a={}){
console.log(a['firstName']);
}
I hope this help you if you got this error try this way
thank you