Utilizing strict mode in my code has led to an issue when trying to assign an object value from a Map. Despite the fact that the value obtained from the Map is not undefined, strict mode is throwing the error
Type A[]|undefined isn't assignable to type A[]
.
How can I resolve this compiler error?
let key = "foo"
leaderboardRecords: A[] = [];
leaderboardRecordsbyRegion: Map<string, A[]> = new Map<string, A[]>();
if (!leaderboardRecordsbyRegion.has(key)) {
leaderboardRecordsbyRegion.set(key, fetchData());
}
leaderboardRecords = leaderboardRecordsbyRegion.get(key);