I have the following TypeScript code:
class ClassA {
options: ClassOption;
B: ClassB;
constructor() {
this.B = new ClassB(this.options);
this.changeOptions();
}
changeOptions(): void {
const newOptions: ClassOption = new ClassOption("something");
this.options = newOptions;
}
}
class ClassB {
options: ClassOption;
constructor(opts: ClassOptions) {
this.options = opts;
}
someFunction(): ClassOption {
return this.options;
}
}
The problem is that when I instantiate ClassA:
const a = new ClassA();
a.B.someFunction(); returns undefined instead of the new options that are set from ClassA's changeOptions method.