interface Incrementor {
(x: number): number;
increment: number;
}
const a: Incrementor = function (x) { return 111 };
a.increment = 111;
let a1: Incrementor = function (x) { return 111 };
a1.increment = 111;
When using let, an error message appears saying "Property 'increment' is missing in type '(x: number) => number' but required in type 'Incrementor'". However, this error message does not appear when using const.
What's the difference between using let and const in this scenario?
You can view the original code here: https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgJIgVCBbC4D2UyA3gFDLIAUAHgFzIgCu2ARtAJT1OvQDc5yUJhx4wXZmyj8AvqVIJ8IAM5hkceumG4CRALzIYjDGGCKq1diWRYwjKCGQBGZ8mn84AOiFZtq-c8d+UgAbCFU4Rw0MH1FCZH1DY1MHGktiazC7BwDXd0cvaJFweKdnXiA