Previous inquiries on this topic have left me with unanswered questions.
As a newcomer, I've been exploring TypeScript's import and export functionality. Below is the code snippet I've come up with. Your feedback would be greatly appreciated.
I've divided my files into three:
1.animal.ts
2.bird.ts
3.application.ts
Animal.ts:-
export class Animal {
name:string
age:number
constructor(name:string,age:number){
this.name=name;
this.age=age
}
sleep(){
console.log("I do sleep")
}
eat(){
console.log("I do eat")
}
}
bird.ts
import {Animal} from "./animal"
export class Bird extends Animal{
constructor(name:string,age:number){
super(name,age)
}
fly(){
console.log("I can fly also")
}
}
application.ts
import { Animal } from "./animal"
import { Bird } from "./bird"
class Application {
constructor() {
console.log("Hi i am a bird !!")
}
}
var animal = new Animal("Rhino", 10);
var bird = new Bird("Pigeon", 3)
animal.age(); //Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures
animal.name(); //Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
bird.age(); //Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures
bird.fly();
bird.sleep();
What steps should I take to resolve this issue? And could you explain what this error message really signifies?