I am currently new to Typescript programming and in the learning phase. I encountered a problem while coding and received an error in the backend console. Here is the code snippet that caused the error:
function employee(id:number,name:string) {
this.id = id
this.name = name
}
var emp = new employee(123,"Smith")
employee.prototype.email = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e2918f8b968aa2838081cc818d8f">[email protected]</a>"
console.log("Employee 's Id:" +emp.id)
console.log("Employee's name:"+emp.name)
console.log("Employee's Email ID:"+emp.email)
The output on the browser console is as follows:
www.ts:10 Employee 's Id: 123
www.ts:11 Employee's name: Smith
www.ts:12 Employee's Email ID: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dba8b6b2afb39bbab9b8f5b8b4b6">[email protected]</a>
The error in the Node console is:
[0] www/www.ts(6,15): error TS7009: 'new' expression, whose target lacks
a construct signature, implicitly has an 'any' type.
I would appreciate any help in resolving this issue. Thank you....