【发布时间】:2017-02-03 09:47:14
【问题描述】:
我在 Vue.js 中使用 flowtype,并为 Vue.js 添加了类型声明。 然后,我还将 JSX 语法与 babel-plugin-transform-vue-jsx 一起使用。
虽然我想将 JSX 标签键入为 VNode,但 flowtype 引擎将 JSX 标签检测为 React$Element,所以它不起作用。
有没有人知道让 flowtype 引擎将 JSX 检测为另一种类型的方法或知道解决此问题的其他好方法?
我需要你的帮助。
谢谢。
全部代码都在这里。 https://github.com/kentrino/vue-js-webpack-flowtype-example
import style from './Test.css';
const test: ComponentOptions = {
render (h): VNode {
return <div><h1 class={style.red}>Yeah!! This is test.</h1></div>
// ^^^^^ React$Element. This type is incompatible with
// 5: render (h: any): VNode {
// ^^^^^ VNode
},
name: 'Test'
}
【问题讨论】:
-
我即将尝试做同样的事情......(将 flowtype 和 JSX 与 React 以外的库一起使用)我会让你知道我发现了什么......但是缺乏这里的答案意味着它可能不适合我们...