2016-12-28 58 views
2

我想用Reforma組件的繼承使用多態性,但是我看到「這種類型與V的一些不兼容的實例不兼容」錯誤。Flowtype多態性不能正常工作

下面是代碼:

// @flow 

import React, { Component } from 'react' 

type BaseProps = { 
    name: string 
} 

type BaseState<T> = { 
    error: string, 
    value: ?T, 
} 

class Base<Props, V> extends Component<any, BaseProps & Props, BaseState<V>> { 
    state = { 
     error: '', 
     value: null, 
    } 
    render() { 
     return <div>this.props.name</div> 
    } 
} 


type ExtendedProps = { 
    foo: string, 
} 

class ExtendedBase extends Base<ExtendedProps, string> { 
    render() { 
     return <div>this.props.name</div> 
    } 
} 

Link to Playground

我在做什麼錯?

回答