Given the following Typescript interfaces, how should I set user
to accept interface Baseball, Basketball, or Football, where properties vary?
Currently, the only properties accessible are those which overlap. In this example being user.stats.A
.
I am working within Vue 3's Composition API.
interface Profile {
firstName: string
lastName: string
status: string
}
export interface Baseball extends Profile {
stats {
A: string
B: string
...
}
}
export interface Basketball extends Profile {
stats {
A: string
C: string
...
}
}
export interface Football extends Profile {
stats {
A: string
D: string
...
}
}
setup(){
const user = reactive<Baseball | Basketball | Football>({
firstName: 'Michael'
lastName: 'Jordan'
status: 'GOAT'
stats: {
...basketball specific properties
}
}
})