How to write Definition File for React JSX

六月ゝ 毕业季﹏ 提交于 2019-12-01 10:58:24

问题


I want to write a custom definition file for Summernote.jsx so that i dont get react-summernote module not found

i have written

declare var ReactSummernote: JSX.ElementClass;

declare module "react-summernote" {

    export default ReactSummernote;
}

and imported this as

import ReactSummernote from 'react-summernote';

but got an error saying

"JSX element type 'ReactSummernote' does not have any construct or call signatures"
on
<ReactSummernote />

following is the link

Summernote.JSX


回答1:


You can just declare the module as:

declare module "react-summernote";

Or more specifically:

declare module "react-summernote" {
    import * as React from "react";
    let ReactSummernote: React.ComponentClass<any>;
    export default ReactSummernote;
}


来源:https://stackoverflow.com/questions/42547859/how-to-write-definition-file-for-react-jsx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!