Exploring the world of TypeScript has left me puzzled by a scenario where TypeScript does not perform type checking as expected. I'm running into an issue where 'this.a.method()'
appears to be error-free when it should actually throw an error. Ideally, TypeScript would alert me that a.method()
needs a parameter value of type string
. What might be the factor causing this discrepancy?
class A {
method(value: string){
console.log(value);
}
}
class B {
constructor(private a){}
call(){
this.a.method()
}
}
const a = new A();
const b = new B(a);
b.call();