I am new to Typescript and was exploring the function type. Please help me understand why the following snippet is not throwing error.
interface Person {
firstName: string,
age?: number,
sayHello(name: string): void
}
let chethan:Person = {
firstName: "chethan",
sayHello: function() {
return 1;
}
}
As you can see here, in my interface I have mentioned that sayHello should accept a string and return void. But when I gave a default value to "chethan" obj the sayHello is not accepting string parameter and also returning number instead of void. But Typescript is not throwing any error.