Within my class, I have set the type of range
to IntervalRange
.
export class Test {range: IntervalRange;}
Then, in the parent class, I initialize the value:
export class TestInitializer {
Create(){
return <Test>{
range: IntervalRange.initialize(Database.GetByName('MONTH').id};
}
InitializeElement() {
let test = <Test>JSON.parse(JSON.stringify(configuration));
return test;
}
In another component, I use this as:
@Input() range: IntervalRange;
However, when calling the function range.getRange();
,
an error is thrown:
ERROR TypeError: this.range.getRange is not a function
This is puzzling, as it indicates that range
is an Object when it should be an IntervalRange
.
I attempted using as IntervalRange
and <IntervalRange> range
but nothing resolved the issue. How can this be fixed?
Update: let type = typeof(this.range)
; outputs "object"
Here is the method:
ngOnChanges() {
if (this.range) {
let type = typeof(this.range);
let ddd = this.range.getRange(); //<----- this is where I encounter the error
}