请参阅下面的flowtry。第17行是联合类型和对象文字之间的联合。当我在第36行使用类型时,它告诉我它找不到联合中类型的属性。
有谁知道我在这里做错了什么?
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)
}
}
谢谢