Mám kontexte služieb, ktoré prúdy údajov užívateľa v celej app.
Som Študent rozhranie:
export interface Student extends User
Chcela by som, aby služieb, ak sa chcete vrátiť údaje používateľa typu Student
alebo User
a dopĺňa takto:
let userData: Student | User = null;
Pri pokuse o prístup k majetku, k dispozícii len pre študentov, userData?.currentTeam
, VS Kód hodí nasledujúce chybové hlásenie:
Property 'currentTeam' does not exist on type 'Student | User'.
Property 'currentTeam' does not exist on type 'User'.ts(2339)
Potrebujem pomôcť zistiť, prečo je default materskej rozhranie a ako povoliť možnosť oboch.
'currentTeam' in userData ? userData.currentTeam.teamName: 'No Team Set'