Currently, I am facing an issue with my interface properties while trying to access a service. The error message I encountered is - Type 'undefined' is not assignable in displayfile at this.isOpen
. Any assistance in resolving this error would be greatly appreciated.
Please note that altering values in the config file like
"strictNullChecks":false
is not an option for me.
The Interface I'm working with is as follows:
export interface DataFile {
file?: DataFile[];
location: string;
}
Here is a snippet of my Typescript class:
isOpen?: DataFile;
Scan(aero: string, TeamClass: string) {
if (TeamClass === 'Hawkins') {
if (this.redService.name.file && this.redService.name.file.length > 0) {
this.isOpen = this.redService.name.file.filter((data: DataFile) => data.location == aero[0])[0];
}
}
this.displayfile(this.isOpen).then(async () => {
//rest of the functionality
}
}
});
}
The specific error I'm encountering is:
Argument of type 'DataFile | undefined' is not assignable to parameter of type
'DataFile'.
Type 'undefined' is not assignable to type 'DataFile'.