【问题标题】:Add autocomplete to Typescript/React component向 Typescript/React 组件添加自动完成功能
【发布时间】:2020-12-12 06:41:36
【问题描述】:

我有一个在 NPM 上发布的组件(typescript + react)。我想为我制作这个组件的 IntelliSense 自动完成 React 道具。对于普通的 react 组件,我使用了 js doc,但在这里不起作用。

组件示例:

class MyComp extends React.Component<
  MyCompPropsInterface,
  MyCompComponentState
  > {...} 

索引文件

 import { MyComp } from './components/MyComp ';

 export { MyComp };

如果我遗漏了什么,请指出,我会添加它。

【问题讨论】:

    标签: reactjs typescript visual-studio-code


    【解决方案1】:

    所以我发现了问题,我没有将我的接口传递给构造函数。

    应该如何:

    class MyComp extends React.Component<
     MyCompPropsInterface,
     MyCompComponentState
     > {
    constructor(
       public props: ImagePropsInterface,
     ) 
    } 
    

    【讨论】:

      猜你喜欢
      • 2014-09-28
      • 1970-01-01
      • 1970-01-01
      • 2021-11-22
      • 2014-07-16
      • 1970-01-01
      • 2018-04-23
      • 1970-01-01
      相关资源
      最近更新 更多