Reputation: 59
Please see flowtry below. Line 17 is a union between a union type and an object literal. When I use the type on line 36, it tells me it can't find the properties of the type within the union.
Does anyone know what I'm doing wrong here?
type NativeMockPlayerSourceConfig = {}
type BitmovinPlayerSourceConfig =
| BitmovinPlayerSourceConfigHLS
| BitmovinPlayerSourceConfigDash
type BitmovinPlayerSourceConfigHLS = {
tag: 'HLS',
hls: string,
}
type BitmovinPlayerSourceConfigDash = {
tag: 'DASH',
dash: string,
}
type LiveSourceConfig = BitmovinPlayerSourceConfig | NativeMockPlayerSourceConfig
interface NativePlayer {
+load: LiveSourceConfig => Promise<void>,
}
type NativeBitmovinPlayer = {
load: BitmovinPlayerSourceConfig => Promise<NativeBitmovinPlayer>,
}
type PromisePassthrough<C: any> = any => Promise<C>
type NativeMockPlayer = {
load: PromisePassthrough<NativeMockPlayer>,
}
class BitmovinPlayer implements NativePlayer {
ref: NativeBitmovinPlayer
async load(source: BitmovinPlayerSourceConfig) {
await this.ref.load(source)
}
}
class MockPlayer implements NativePlayer {
ref: NativeMockPlayer
async load(config: NativeMockPlayerSourceConfig) {
this.ref.load(config)
}
}
Thank you
Upvotes: 1
Views: 47